Skip to content

Instantly share code, notes, and snippets.

@antonyalkmim
Created June 22, 2018 22:28
Show Gist options
  • Save antonyalkmim/12c29cdfc4f3cc6c4b2d62db1a80bd62 to your computer and use it in GitHub Desktop.
Save antonyalkmim/12c29cdfc4f3cc6c4b2d62db1a80bd62 to your computer and use it in GitHub Desktop.
infix operator ?!: NilCoalescingPrecedence
@_transparent
public func ?!<T: OptionalType>(value: T, error: @autoclosure () -> Error) throws -> T.ValueType {
if let value = value.optionalValue { return value }
throw error()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment