Created
October 6, 2017 21:18
-
-
Save samsonjs/c8933c07ad985b74aba994f2fdab8b47 to your computer and use it in GitHub Desktop.
A hack to improve compile times by avoiding the nil-coalescing operator (??)
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
extension Optional { | |
func or(_ defaultValue: Wrapped) -> Wrapped { | |
switch self { | |
case .none: return defaultValue | |
case let .some(value): return value | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment