Skip to content

Instantly share code, notes, and snippets.

@timshadel
Created July 1, 2016 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timshadel/3ec5ff204eab9cd9c0bcaefeebc63285 to your computer and use it in GitHub Desktop.
Save timshadel/3ec5ff204eab9cd9c0bcaefeebc63285 to your computer and use it in GitHub Desktop.
From Dave D.
infix operator !! { associativity left precedence 160 }
@inline(__always) public func !!<T>(value: T?, @autoclosure die: () -> Void) -> T {
guard let value = value else {
die()
exit(-1)
}
return value
}
let test: String? = nil
let foo = test !! fatalError("what?!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment