Skip to content

Instantly share code, notes, and snippets.

@duboisf
Created April 22, 2010 01:20
Show Gist options
  • Save duboisf/374687 to your computer and use it in GitHub Desktop.
Save duboisf/374687 to your computer and use it in GitHub Desktop.
Creating a while loop function
object WhileClosure extends Application {
def While(cond: => Boolean)(body: => Unit): Unit = {
if (cond) {
body
While(cond)(body)
}
}
var x = 0
While(x < 10) {
x += 1
println(x)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment