On Friday, 10 March 2017 at 16:13:21 UTC, Adam D. Ruppe wrote:
On Friday, 10 March 2017 at 16:08:05 UTC, DRex wrote:
Am I missing something here?
Yeah, you need to implement a custom equality operator.
class A {
int member;
override bool opEquals(const A rhs) {
return this.member == rhs.member; // and other members
that need to be equal
}
}
The default opEquals sees if they are the same *instance* (same
as `a is b`), and does not look at contents. You need to define
that yourself.
I tried the above class A, and now the compiler fails with the
following error:
Error: function app.A.opEquals does not override any function,
did you mean to override 'object.Object.opEquals'?
My A class appears exactly as mentioned in your comment...