Comparison

Namespace rswhite4 at googlemail.com
Tue Nov 26 14:00:27 PST 2013


On Tuesday, 26 November 2013 at 21:37:49 UTC, Jonas Drewsen wrote:
> Isn't it a bug that the assertion is triggered for this:
>
> class Test3 {}
>
> void main()
> {
> 	assert( (new Test3()) == (new Test3()) );
> }
>
> Tried it on http://dpaste.dzfl.pl/ as well.
>
> /Jonas

Because your Test3 class has probably no own opEquals method, 
your comparison is the same as
assert( (new Test3()) is (new Test3()) );
which is obviously wrong.

See: 
https://github.com/D-Programming-Language/druntime/blob/master/src/object_.d#L116


More information about the Digitalmars-d-learn mailing list