Skip to content

Instantly share code, notes, and snippets.

@tednaleid
Created June 17, 2010 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tednaleid/442580 to your computer and use it in GitHub Desktop.
Save tednaleid/442580 to your computer and use it in GitHub Desktop.
def findResult (collection, closure) {
for ( value in collection) {
def result = closure(value)
if (result != null) return result
}
}
assert "5foo" == findResult([1, 2, 3, 4, 5, 6, 7]) {
if (it >= 5) return "${it}foo"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment