This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The correct implementation of `Equatable` (and `Comparable`) can be tricky for class | |
// hierarchies. To make it easier, it is better to follow a well-defined pattern. Here | |
// is my suggestion on how to do it: | |
// 1. Define a protocol for polymorphic test function for equality (or comparison): | |
// Note: operators are not polymorphic (not virtual in C++ terms)). The function to | |
// call is determined and hard-coded at compile time. | |
/// A protocol to ammend `Equatable` for use with `class` types. |