Skip to content

Instantly share code, notes, and snippets.

@landonf
Last active August 29, 2015 14:02
Show Gist options
  • Save landonf/faa8867dd45ff6b4dd56 to your computer and use it in GitHub Desktop.
Save landonf/faa8867dd45ff6b4dd56 to your computer and use it in GitHub Desktop.
Swift vs Scala, FIGHT
// Example totally stolen from Mike Ash
1> func lameFor(count: Int, body: @auto_closure () -> ()) { for _ in 0..count { body() } }
2>
3> lameFor(3, println("I'm the greetest"))
I'm the greetest
I'm the greetest
I'm the greetest
// Now, in Scala
scala> def lameFor(count:Int, body: => Unit) = for (_ <- 0 until count) body
lameFor: (count: Int, body: => Unit)Unit
scala> lameFor(3, println("You look oddly familiar"))
You look oddly familiar
You look oddly familiar
You look oddly familiar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment