Now that your Point type conforms to the Equatable protocol, you may be interested in more nuanced forms of comparison. For example, perhaps you want to know if a point is less than another point. You accomplish this functionality by conforming to the Comparable protocol.
Open the documentation for Comparable.
Because you have not entered Comparable yet (so you cannot Option-click on its name), click on the Help menu and select Documentation and API Reference.
Search for “Comparable” to determine what is needed.
You will find that you need to implement one operator: the
< infix operator.
Add the following code to your struct to make it conform to Comparable.
Listing 25.7 Conforming to