Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does Find() work on a map? #165

Open
jeffsaremi opened this issue Jun 15, 2023 · 1 comment
Open

Does Find() work on a map? #165

jeffsaremi opened this issue Jun 15, 2023 · 1 comment

Comments

@jeffsaremi
Copy link

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"
 }
@nguyenvantuan2391996
Copy link

nguyenvantuan2391996 commented Aug 8, 2023

@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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants