Back to Lo

Core Findkeyby

docs/data/core-findkeyby.md

1.53.0215 B
Original Source

Returns the first key in the map for which the predicate returns true.

go
k, ok := lo.FindKeyBy(map[string]int{"foo":1, "bar":2, "baz":3}, func(k string, v int) bool {
    return k == "foo"
})
// "foo", true