We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The value of initialAge is set at the bottom of the problem, when the Person object ("p") is created
let age = Int(readLine(stripNewline: true)!)!
var p = Person(initialAge: age)
p.amIOld()
If the "age" is twenty the line "var p = Person(initialAge: age)" can be though of as "var p = Person(20)". In the constructor the 20 can be compared then. I hope this helps.
Day 4: Class vs. Instance
You are viewing a single comment's thread. Return to all comments →
The value for initialAge in
is passed whan you create a Person object.
The value of initialAge is set at the bottom of the problem, when the Person object ("p") is created
If the "age" is twenty the line "var p = Person(initialAge: age)" can be though of as "var p = Person(20)". In the constructor the 20 can be compared then. I hope this helps.