Does Find() work on a map?
jeffsaremi opened this issue · comments
Jeff Saremi commented
I can't get this to work:
mymap := map[string]string {
"one": "1",
"two": "2",
}
key, value := funk.Find(mymap, func(k,v string) bool {
return v == "2"
}
Tuan Nguyen Van commented
@jeffsaremi funk find supports funcition has one input parameter and one output response. The type of input is the type of element in the array or map. The type of output is bool.
Code fix
mymap := map[string]string{
"one": "1",
"two": "2",
}
value := Find(mymap, func(v string) bool {
return v == "2"
})
fmt.Println(value) // "2"