Skip to content

Instantly share code, notes, and snippets.

@ahti
Created June 7, 2014 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahti/fe32cca03694699b00ce to your computer and use it in GitHub Desktop.
Save ahti/fe32cca03694699b00ce to your computer and use it in GitHub Desktop.
Swift @auto_closure
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