Skip to content

Instantly share code, notes, and snippets.

@konrad1977
Created June 12, 2015 12:21
Show Gist options
  • Save konrad1977/e9091c25b629410eb26e to your computer and use it in GitHub Desktop.
Save konrad1977/e9091c25b629410eb26e to your computer and use it in GitHub Desktop.
guard statement
func greetingsForOptionals(name: String?) {
guard let unwrappedName = name where unwrappedName.characters.count != 0 else {
return
}
print("Greetings \(unwrappedName)")
}
var name: String? = "FooBar"
greetingsForOptionals(name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment