equatable
Implement Equatable protocol with Inheritance
To implement the equatable protocol is as simple as follow:
But the problem is, if you have an subclass, it is not going to work.
Because when you comparing two SimpleSubClass
objects, only the super class's ==
function is called.
Solution
Add an extra equals
function that can be overriden in subclass
References
Last updated
Was this helpful?