Misunderstanding, silly error, or compiler bug?
Peter C. Chapin
pchapin at sover.net
Fri Aug 10 07:11:44 PDT 2007
Peter C. Chapin wrote:
> Interesting. Okay, so I'm trying to compare the Node referenced by
> currrent to null. I didn't define an opEqual for class Node so does that
> mean the compiler gives me a default one? I guess I would have expected
> some sort of type mismatch error ('null' isn't a Node, after all).
I think I answered my own question on this. I now understand that == and
!= do value comparisons. Thus even though the right parameter is a
reference, the operator is intended to access the object pointed at by
that reference to render its decision. Thus something like
current == null
is doomed to failure even if 'current' refers to a real object because
opEqual is going to want to dereference null.
Peter
More information about the Digitalmars-d-learn
mailing list