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

Swift 3 - Pet Protocol Challenge Task 1 of 2: How do I correct method requirement error?

Challenge Task 1 of 2

In the editor, I've provided a simple protocol to represent an animal.

For the first task, create a protocol named Pet which should inherit from Animal and require an additional gettable stored property, cuddlyName, of type String.

I thought what I had was correct, but I keep getting an error telling me to add the required method. Task one does not mention anything about a method.

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

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

I changed let cuddlyName to var cuddlyName and it passed!

protocol Animal {
  var numberOfLegs: Int { get }
}

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

These aren't the codes you're looking for. Move along, move along.