Behavior of opEquals
Jacob Carlborg via Digitalmars-d
digitalmars-d at puremagic.com
Sat Sep 5 02:45:35 PDT 2015
On 2015-09-05 08:26, Jonathan M Davis wrote:
> Clearly, you haven't read TDPL recently enough. ;)
>
> There is a free function, opEquals, in object.d which gets called for
> classes, and _it_ is what == gets translated to for classes, and it
> calls the member function version of opEquals on classes:
>
> https://github.com/D-Programming-Language/druntime/blob/master/src/object.d#L143
>
>
> This allows us to avoid a number of fun bugs with opEquals that you get
> in languages like Java and makes it completely unnecessary to do stuff
> like check whether the argument to opEquals is null. Timon gave the link
> to the explanation in the spec:
Bu you don't see my example as a problem?
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list