Skip to content

Instantly share code, notes, and snippets.

@sammoore
Created August 2, 2016 19:50
Show Gist options
  • Save sammoore/75fc63689251d942aed3e545a93ceaff to your computer and use it in GitHub Desktop.
Save sammoore/75fc63689251d942aed3e545a93ceaff to your computer and use it in GitHub Desktop.
Playing with custom operators by adding syntactic sugar / alternative cast operators.
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