Skip to content

Instantly share code, notes, and snippets.

@rtauziac
Created February 7, 2019 17:18
Show Gist options
  • Save rtauziac/2981473dbc43c4d593645c34e91b6f4d to your computer and use it in GitHub Desktop.
Save rtauziac/2981473dbc43c4d593645c34e91b6f4d to your computer and use it in GitHub Desktop.
Use optionals with the C# style
extension Optional {
var hasValue: Bool {
return self != nil
}
var value: Wrapped {
return self!
}
func value(orDefault defaultValue: Wrapped) -> Wrapped {
return self ?? defaultValue
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment