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 trialJohn Gu
6,891 Pointsstruct Dog not conforming to protocol
I'm trying to set the struct Dog to conform to the protocol, per the challenge, but I can't figure out what I'm doing wrong vis-a-vis the challenge. The struct has all the variables in the protocols, but it still is not accepted by the treehouse compiler.
protocol Animal {
var numberOfLegs: Int { get }
}
protocol Pet : Animal {
var cuddlyName: String { get }
}
struct Dog : Pet {
let numberOfLegs : Int
let cuddlyName : String
}
1 Answer
Claire Worrmald
6,442 PointsMy code is exactly the same as yours and I was able to pass through to the next video and have the challenge completed. Hmmm must be something up teamtreehouse website, do a hard refresh, empty your cache and use safari and try again. Because I have tried again and my solution goes through ok again.
protocol Animal {
var numberOfLegs: Int { get }
}
protocol Pet: Animal {
var cuddlyName: String { get }
}
struct Dog: Pet {
var cuddlyName: String
var numberOfLegs: Int
}