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 trialDan Sabin
Courses Plus Student 1,909 PointsIt seems like the either the prompt or the check are not in sync for this question. Any idea on how to proceed
I've tried creating a gettable type, but the "error" says I need to make a function. I tried guessing what function they might be asking to see if the prompt would change and give me more information, no luck. Not sure how to proceed.
protocol Animal {
var numberOfLegs: Int { get }
}
protocol Pet: Animal {
let cuddlyName: String { get }
}
1 Answer
Charles Kenney
15,604 PointsThe problem is, you set your Pet protocol's gettable 'cuddlyName' property to a constant when it should be a variable. Your protocols should look like this:
protocol Animal {
var numberOfLegs: Int { get }
}
protocol Pet: Animal {
var cuddlyName: String { get }
}
So our struct, dog should look like this:
struct dog: Pet {
var numberOfLegs: Int
var cuddlyName: String
}
Hope this answers your question. -Charles