-
-
Save edopelawi/0a199ded65b76108233cf7a43a95cc00 to your computer and use it in GitHub Desktop.
A sample on unwrapping String optional using switch's pattern matching.
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
func printSailorName(sailorName sailorName: String?) { | |
switch sailorName { | |
case .some(let validName): | |
print(createGreetings(sailorName: validName)) | |
case .none: | |
print("👺 The sailor name input is invalid!") | |
} | |
} | |
printSailorName(sailorName: nil) | |
printSailorName(sailorName: name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment