Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@auto_closure for control over evaluation
func myAnd(lhs : Bool, rhs : @auto_closure () -> Bool) -> Bool {
if lhs {
return rhs()
} else {
return false
}
}
func logAndBool(val : Bool) -> Bool {
println("evaluating and returning \(val)!")
return val
}
var res = myAnd(logAndBool(false), logAndBool(true))
// log reads "evaluating and returning false!", does not contain a log for true.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.