Skip to content

Instantly share code, notes, and snippets.

@bdkosher
Last active August 29, 2015 14:13
Show Gist options
  • Save bdkosher/ed5ad99fa7cfb0817c26 to your computer and use it in GitHub Desktop.
Save bdkosher/ed5ad99fa7cfb0817c26 to your computer and use it in GitHub Desktop.
Faking a do-while construct using Groovy (which does not support the do keyword currently)
def _ = [do: { body ->
[while: { condition ->
body()
if (condition()) call(condition)
}]
}]
int i = 0; _.
do {
println(++i)
}.while { i < 5 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment