Skip to content

Instantly share code, notes, and snippets.

@bakkdoor
Created December 15, 2012 19:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bakkdoor/4298687 to your computer and use it in GitHub Desktop.
Save bakkdoor/4298687 to your computer and use it in GitHub Desktop.
Sample implementation of while loop with additional else branch, if loop doesn't get executed (in Fancy).
class Object {
def while: condition do: body else: alternative {
if: (condition call) then: {
body call
while: condition do: body
} else: alternative
}
}
# usage:
while: { 100 random > 25 } do: {
"Got a random number > 25" println
} else: {
"Failed to get a random number > 25" println
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment