Created
October 26, 2015 21:55
-
-
Save sssionggg/818594918d63e84cc2cd to your computer and use it in GitHub Desktop.
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 personName(firstName: String, lastName: String?) -> String { | |
guard let lastName = lastName else { | |
return "\(firstName)" | |
} | |
return "\(firstName) \(lastName)" | |
} | |
personName("Siong", lastName: "Ong") // prints "Siong Ong" | |
personName("Siong", lastName: nil) // prints "Siong" | |
personName("Siong") // This dosen't work but it should, nil should be auto-assigned to optional parameter :( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment