Files
lo/docs/data/core-maptoslice.md
T
Samuel Berthe fa095e4b4f fix(doc): fix go playground demo URL (#832)
* fix(doc): fix go playground demo URL

* fix(doc): add more go playground demo URL
2026-03-06 00:09:59 +01:00

32 lines
691 B
Markdown

---
name: MapToSlice
slug: maptoslice
sourceRef: map.go#L367
category: core
subCategory: map
playUrl: https://go.dev/play/p/4f5hbHyMf5h
variantHelpers:
- core#map#maptoslice
similarHelpers:
- core#map#mapentries
- core#map#entries
- core#slice#map
- core#slice#mapentries
- core#map#maptosliceerr
position: 210
signatures:
- "func MapToSlice[K comparable, V any, R any](in map[K]V, iteratee func(key K, value V) R) []R"
---
Transforms a map into a slice by applying an predicate to each key/value pair.
```go
m := map[int]int64{1:4, 2:5, 3:6}
s := lo.MapToSlice(m, func(k int, v int64) string {
return fmt.Sprintf("%d_%d", k, v)
})
// []string{"1_4", "2_5", "3_6"}
```