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

The correct answer does not seem to be accepted.

The code I submitted is not accepted as an answer. I have had this problem before and clearing the browser cache helped last time. This time however, it does not.

protocols.swift

4 Answers

Chris Stromberg
PLUS
Chris Stromberg
Courses Plus Student 13,389 Points

I think its working now. I had to reload the page a few times before it would accept the correct answer.

Somehow the code was not pasted in. Here it goes:

protocol Animal { var numberOfLegs: Int { get } }

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

struct Dog : Pet { var numberOfLegs = 4 var cuddlyName = "Test" }

There are normally more line breaks, of course.

Chris Stromberg
PLUS
Chris Stromberg
Courses Plus Student 13,389 Points

This code doesn't belong in the answer:

struct Dog : Pet { var numberOfLegs = 4 var cuddlyName = "Test" }

Otherwise its correct.