mirror of
https://github.com/samber/lo.git
synced 2026-04-22 15:37:14 +08:00
fa095e4b4f
* fix(doc): fix go playground demo URL * fix(doc): add more go playground demo URL
30 lines
643 B
Markdown
30 lines
643 B
Markdown
---
|
|
name: RejectMap
|
|
slug: rejectmap
|
|
sourceRef: slice.go#L550
|
|
category: core
|
|
subCategory: slice
|
|
playUrl: https://go.dev/play/p/bmXhtuM2OMq
|
|
variantHelpers:
|
|
- core#slice#rejectmap
|
|
similarHelpers:
|
|
- core#slice#filtermap
|
|
- core#slice#map
|
|
- core#slice#filter
|
|
- core#slice#reject
|
|
position: 270
|
|
signatures:
|
|
- "func RejectMap[T any, R any](collection []T, callback func(item T, index int) (R, bool)) []R"
|
|
---
|
|
|
|
Opposite of FilterMap: maps each item and includes results where the predicate returned false.
|
|
|
|
```go
|
|
items := lo.RejectMap([]int{1, 2, 3, 4}, func(x int, _ int) (int, bool) {
|
|
return x * 10, x%2 == 0
|
|
})
|
|
// []int{10, 30}
|
|
```
|
|
|
|
|