Created
November 10, 2017 00:19
-
-
Save yabenatti/9e981920054e29d5e8145e74b8c3bfdf to your computer and use it in GitHub Desktop.
MiniCursoIFSPSwiftOptionals
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
var optionalString: String? = nil | |
if let unwrappedOptionalWithIf = optionalString { | |
print("Use \(unwrappedOptionalWithIf) here") | |
} | |
func printString(string: String?) { | |
guard let unwrappedOptionalWithGuard = optionalString else { | |
print("Treat error") | |
return | |
} | |
print("Use \(unwrappedOptionalWithGuard) here") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment