Last active
August 29, 2015 14:02
-
-
Save landonf/faa8867dd45ff6b4dd56 to your computer and use it in GitHub Desktop.
Swift vs Scala, FIGHT
This file contains hidden or 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
// 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 |
This file contains hidden or 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
// 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