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 trialJustin Janes
5,904 PointsI have this same code snippet open in Xcode with no errors or warnings and the preview button isn't showing any compiler
I've tested this out in Xcode and I don't see any errors or warnings there - I've tried treating the inheritance by assigning the variables to self.cuddlyName etc. but that results in errors. I've re-watched the video but the video focuses on implementing inheritance of functions not simply variables inside of a struct.
protocol AnimalType {
var numberOfLegs: Int { get }
}
protocol PetType: AnimalType {
var cuddlyName: String { get }
}
struct dog: PetType {
var cuddlyName = "Boba"
var numberOfLegs = 5
}
1 Answer
Jennifer Nordell
Treehouse TeacherOh you're going to love this! Your code is fine. This is an example of the challenge being picky. You named your struct dog
. It wants the struct to be named Dog
. Note the capitalization. If I take your code and copy/paste it into the challenge and make that tiny change, your code passes! Happy coding!