Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Protocols in Swift Creating Flexible Objects Using Protocols Protocol Inheritance

Can someone help me, please? This could should work i don't know what is wrong.

It should be an easy fix

protocols.swift
protocol Animal {
    var numberOfLegs: Int { get }
}
protocol Pet: Animal  {
    var cuddlyName: String  { get }
}

2 Answers

I just typed this in the challenge and it worked:

protocol Animal {
    var numberOfLegs: Int { get }
}
protocol Pet: Animal {
    var cuddlyName: String { get }
}

Your code did not work in the challenge because the challenge is bugged. You typed 2 white spaces before Pet's curly bracket and before cuddlyName: String 's curly bracket. This doesn't change anything in Xcode but it affects the bugged challenge.

It works for me in Xcode.

Yeah, the code works in XCode but not in the challenge.