-
-
Save edopelawi/1e780ffac24bc85b1173c2e5ba1ae65f to your computer and use it in GitHub Desktop.
A sample on unwrapping String optional using guard let and return early strategy.
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 guardLetEarlyReturnFunction(sampleName: String?) { | |
guard let validName = sampleName else { | |
print("👺 \(#function): Invalid name provided!") | |
return | |
} | |
print(createGreetings(sailorName: validName)) | |
// Add whole other code here :) | |
} | |
guardLetEarlyReturnFunction(nil) | |
guardLetEarlyReturnFunction(name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment