Created
May 8, 2017 12:40
-
-
Save Sajjon/677cbf085246ac03e9df18e5a18b757f to your computer and use it in GitHub Desktop.
Using emoji char ⁉️ for highlighting usage of force unwrap of optionals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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