Assuming your collection was a list, you can use curry to populate an additional closure parameter with your object:
def someColl = ["foo", "bar", "foo", "baz", "foo"] def filterClosure = { it, param -> it.getParam == param } myColl = someColl.findAll(filterClosure.curry([getParam:'foo'])) assert ["foo", "foo", "foo"] == myColl
In the filterClosure code above, "it" will be assigned to pass curry as a parameter, and "param" to pass the collection item from findAll. This will not work for a map collection, since findAll takes a closure with one or two parameters for it.
John wagenleitner
source share