Created
August 2, 2016 19:50
-
-
Save sammoore/75fc63689251d942aed3e545a93ceaff to your computer and use it in GitHub Desktop.
Playing with custom operators by adding syntactic sugar / alternative cast operators.
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
prefix operator !! {} | |
prefix operator ?? {} | |
prefix func !!<T, U>(rhs: T) -> U { | |
return rhs as! U | |
} | |
prefix func !!<T, U>(rhs: T) -> U! { | |
return rhs as! U | |
} | |
prefix func ??<T, U>(rhs: T) -> U? { | |
return rhs as? U | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment