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 trial

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.