Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@yabenatti
Created November 10, 2017 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yabenatti/9e981920054e29d5e8145e74b8c3bfdf to your computer and use it in GitHub Desktop.
Save yabenatti/9e981920054e29d5e8145e74b8c3bfdf to your computer and use it in GitHub Desktop.
MiniCursoIFSPSwiftOptionals
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