opEquals does not work?
w0rp
devw0rp at gmail.com
Fri Jun 7 13:58:39 PDT 2013
On Friday, 7 June 2013 at 20:51:13 UTC, Namespace wrote:
> I got it. I must use Object instead of A... How ridiculous. I
> thought this was already fixed...
The class opEquals is quite like .equals in Java. You need to
match the signature of Object, which is implicitly the base class
of all classes. I think I recommend something like this.
override bool opEquals(Object o) const {
auto other = cast(A) o;
// It's probably easy to miss out !is null here, which
matters.
return other !is null && this.id == other.id;
}
More information about the Digitalmars-d-learn
mailing list