-
-
Save edopelawi/0b750417f0fc436a50b78410f5fcb432 to your computer and use it in GitHub Desktop.
A sample on using force-unwrap against an String optional.
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
name = "Ol' Man Jenkins" | |
// This call will work, since it has a valid value. | |
print(createGreetings(sailorName: name!)) | |
name = nil | |
// This call will cause an error, since `name` has no value at this point. | |
print(createGreetings(sailorName: name!)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment