Animizable and Humanizable

In this section, you will make a protocol for the creation of any animal, and call it Animizable. This protocol will make sure that anytime someone creates an animal, it will have the proper properties and methods. A lot of times, the names of protocols have able at the end. These are some of the Swift standard protocols you will commonly come across:

Equatable: You must overload the == operator. This allows you to test your type for equality.

Comparable: You must overload the <, >, <=, and >= operators, which will allow you to compare your custom type.

Printable: You must declare a property of type String called description, which will provide a String-based representation of the type.

Get Learning Swift™ Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.