I want use groovy findAll with my param to filtering closure
filterClosure = { it, param ->
it.getParam == param
}
How can I now call this closure in findAll? Like below?
myColl = someColl.findAll(filterClosure ??? )
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming your collection was a list, you could use curry to populate the extra closure parameter with your object:
In the code above, the filterClosure “it” will be assigned what is passed to curry as a parameter and “param” is passed a collection item from findAll. This wouldn’t work for a Map collection since findAll for it takes a closure with either one or two parameters.