Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTiemoko Bamba
1,923 PointsHi, can somebody help me solve a problem and feels like every time I am getting closer something else pop up lol. Please
class Person { let firstName: String let lastName: String
init(firstName: String, lastName: String) {
self.firstName = firstName
self.lastName = lastName
}
func getFullName() -> String {
return "\(firstName) \(lastName)"
}
}
// Enter your code below
class Doctor: Person {
override func getFullName() -> String {
return getFullName()
}
} let someDoctor = Doctor(firstName: "Sam", lastName: "Smith")
1 Answer
Tatiana Jamison
6,188 PointsHi Tiemoko! Right now, your function definition is a little strange. You're calling getFullName() inside of override definition of getFullName() -- but what you want to do is give it a new return definition, where you're telling it to return "Dr. LastName." You should have something like...
class Doctor : Person {
override func getFullName() -> String {
return "the string you actually want to see"
}
}
... where, of course, "the string you actually want to see" is... well, what you want to see. Hope that helps!
(EDIT: Was missing the function definition in the first pass!)
Tiemoko Bamba
1,923 PointsTiemoko Bamba
1,923 PointsHi Tatiana! I perfectly see the problem now and resolved it. Thanks for your help!