Last active
August 29, 2015 14:13
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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