Created
June 7, 2014 20:54
-
-
Save ahti/fe32cca03694699b00ce to your computer and use it in GitHub Desktop.
Swift @auto_closure
This file contains 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
func onlyIfFoo(str: String, stmt: @auto_closure () -> Any) { | |
if (str == "foo") { | |
stmt() | |
} | |
} | |
onlyIfFoo("bar", println("bar")) | |
onlyIfFoo("foo", println("foo")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment