Skip to content

Instantly share code, notes, and snippets.

@agoiabel
Created January 13, 2018 11:44
Show Gist options
  • Save agoiabel/134a0e5a1862f818e27ee2175879d1ac to your computer and use it in GitHub Desktop.
Save agoiabel/134a0e5a1862f818e27ee2175879d1ac to your computer and use it in GitHub Desktop.
Person {
var firstname: String, var middlename: String?, var lastname: String
func fullName() -> () {
guard let middlename = middlename else {
print("Your fullname is \(firstname) \(lastname)")
return
}
print("Your fullname is \(firstname) \(middlename) \(lastname)")
}
}
let anotherPerson = Person(firstname: "Abel", middlename: nil, lastname: "Adeyemi")
anotherPerson.fullName() //This will not throw an error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment