Skip to content

Instantly share code, notes, and snippets.

@coder36
Created November 19, 2014 14:52
Show Gist options
  • Select an option

  • Save coder36/94aa8fc1c72e5a639da7 to your computer and use it in GitHub Desktop.

Select an option

Save coder36/94aa8fc1c72e5a639da7 to your computer and use it in GitHub Desktop.
When I saw this scala code snippet for the first time...

Circa 2010, when I saw this scala code snippet for the first time, my mind was blown at the possibilities...

object WhileDemo {
  def main( args: Array[String]): Unit = {
    var i = 1
    While( i < 10 ) {
      println( i )
      i+=1
    }
  }
  def While( p: => Boolean ) ( c: => Unit ): Unit = {
    if( p ) { c; While(p)(c) }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment