Skip to content

Instantly share code, notes, and snippets.

@Sajjon
Created May 8, 2017 12:40
Show Gist options
  • Save Sajjon/677cbf085246ac03e9df18e5a18b757f to your computer and use it in GitHub Desktop.
Save Sajjon/677cbf085246ac03e9df18e5a18b757f to your computer and use it in GitHub Desktop.
Using emoji char ⁉️ for highlighting usage of force unwrap of optionals
postfix operator ⁉️
postfix func ⁉️ <Value>(optional: Optional<Value>) -> Value {
return optional! as Value
}
//USAGE
let maybeString: String? = "Foobar"
let maybeString2: String? = nil
print(maybeString⁉️) //prints "Foobar"
print(maybeString2⁉️) //fatalError: unexpectedly found nil while unwrapping an Optional value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment