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 Swift Protocols Creating Flexible Objects with Protocols Building Flexible Objects

Wouldn't Car just conform to protocol Vehicle?

I mean, I'm sure you could do it either way, but it wouldn't conform to numberOfSeats then.

If you just did protocol Car: Vehicle instead, wouldn't it conform to all 3?

2 Answers

I think it should've been. It's a rather poor example / design.

As you've said it, it could go either way. I think Pasan was just trying to make room for the motorcycle example that it can conform to Vehicle protocol while Car conforms to Breakable and Drivable.

Still that is a bad design. Motorcycle and Car should both conform to Vehicle protocol since Vehicle protocol already belongs to Breakable and Drivable.

There is no rational explanation for why Car should conform to both Breakable and Drivable directly when Car would clearly conform to Vehicle