Created
July 31, 2014 19:08
-
-
Save kongtomorrow/4adaf4c3ebc93b6e789b to your computer and use it in GitHub Desktop.
unwrap-or
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 } // associativity/precedence copied from ternary ? : | |
@infix func !||<T>(lhs:T?, rhs:@auto_closure ()->T) -> T { | |
switch lhs { | |
case nil: return rhs() | |
case _: return lhs! | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment