Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A sample on unwrapping String optional using guard let and return early strategy.
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