Last active
August 29, 2015 14:04
-
-
Save lilyball/5fa08916c1f480bae38d to your computer and use it in GitHub Desktop.
`x !|| y` operator to provide the equivalent of `x ? x! : y`
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
operator infix !|| { | |
associativity right | |
precedence 100 | |
} | |
func !||<T>(left: T?, right: @auto_closure () -> T) -> T { | |
if let val = left { | |
return val | |
} | |
return right() | |
} |
Author
lilyball
commented
Jul 24, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment