Skip to content

Instantly share code, notes, and snippets.

@xxtesaxx
Created June 13, 2017 21:11
Show Gist options
  • Save xxtesaxx/33eafee20b8f39deab5e51a0343aa49b to your computer and use it in GitHub Desktop.
Save xxtesaxx/33eafee20b8f39deab5e51a0343aa49b to your computer and use it in GitHub Desktop.
infix operator ???: NilCoalescingPrecedence
extension Optional where Wrapped: Emptyable {
static func ???(left: Wrapped?, right: Wrapped) -> Wrapped {
return left.orWhenNilOrEmpty(right)
}
}
let optionalString: String? = nil
let mandatoryString = optionalString ??? "Default Value"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment