Skip to content

Instantly share code, notes, and snippets.

@samsonjs
Created October 6, 2017 21:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
A hack to improve compile times by avoiding the nil-coalescing operator (??)
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