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 trialCameron Hyatt
5,948 PointssomeDoctor isn't the Doctor type?
I'm a bit lost here. Xcode can compile my code and it works fine but it does say someDoctor is a string and the website is saying to make sure someDoctor is the Doctor type but I'm not sure what I am missing.
Any help would be appreciated!
class Person {
let firstName: String
let lastName: String
init(firstName: String, lastName: String) {
self.firstName = firstName
self.lastName = lastName
}
func fullName() -> String {
return "\(firstName) \(lastName)"
}
}
// Enter your code below
class Doctor: Person {
override func fullName() -> String {
return "Dr. \(lastName)"
}
}
let someDoctor = Doctor(firstName: "Sam", lastName: "Smith").fullName()
1 Answer
Jorge Solana
6,064 PointsHey Cameron!
I believe that the code challenge wants you to first declare the constant someDoctor Doctor typed, and then call the someDoctor fullName function.
Try that and you will pass the challenge.
Hope it helps!
Cameron Hyatt
5,948 PointsCameron Hyatt
5,948 PointsGot it! Tried what you said and found it doesn't even want me to call the fullName method, just to override it and leave it be.