Last active
January 12, 2018 07:18
-
-
Save agoiabel/018bd16c230b7873158b96970f921657 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
class Person { | |
var name: String | |
var gender: String = "Male" | |
init(name: String) { | |
self.name = name | |
} | |
} | |
class Foreigner: Person { | |
var country: String | |
init(name: String, country: String) { | |
super.init(name: name) //use to set the superclass initializer | |
//change the default gender property | |
self.gender = "Female" | |
self.country = country | |
} | |
} | |
var newForeigner: Foreigner = Foreigner(name: "Johndoe", country: "Canada") | |
newForeigner.gender //will return Female since we already changed it in the init method | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment