Skip to content

Instantly share code, notes, and snippets.

@namuan
Created September 18, 2013 12:41
Show Gist options
  • Save namuan/6608612 to your computer and use it in GitHub Desktop.
Save namuan/6608612 to your computer and use it in GitHub Desktop.
Groovy return () if (condition)
def doSomething() {
"Doing something"
}
def ret(Closure c) {
[if: { condition ->
if (condition) c()
}]
}
println ret {
doSomething()
}.if(true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment