Skip to content

Instantly share code, notes, and snippets.

@agoiabel
Created January 13, 2018 11:13
Show Gist options
  • Save agoiabel/a1ade388788cdc90cfff63c371bc6f3e to your computer and use it in GitHub Desktop.
Save agoiabel/a1ade388788cdc90cfff63c371bc6f3e to your computer and use it in GitHub Desktop.
Person {
var firstname: String, var middlename: String?, var lastname: String
func fullName() -> () {
if (middlename != nil) {
print("Your fullname is \(firstname) \(middlename!) \(lastname)")
} else {
print("Your fullname is \(firstname) \(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