Back to Lo

Core Pickby

docs/data/core-pickby.md

1.53.0256 B
Original Source

Returns a map of the same type filtered by a key/value predicate.

go
m := lo.PickBy(
    map[string]int{"foo": 1, "bar": 2, "baz": 3},
    func(key string, value int) bool {
        return value%2 == 1
    },
)
// map[string]int{"foo": 1, "baz": 3}