Skip to content

Instantly share code, notes, and snippets.

@mchakravarty
Created September 12, 2014 07:25
Show Gist options
  • Save mchakravarty/86ce59b6c91d5b89b1d4 to your computer and use it in GitHub Desktop.
Save mchakravarty/86ce59b6c91d5b89b1d4 to your computer and use it in GitHub Desktop.
Abort if nil
infix operator ?! { }
func ?!<A>(v: A?, msg: String) -> A {
if let v = v {
return v
} else {
println(msg)
exit(1)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment