<p>Oh, ok.</p>
<p>First of all the docs appear somewhat misleading. I thought that function was an example on how to overload it. That could be clarified a little.</p>
<p>Second of all, isn't that inefficient? And if you wanted to be able to compare to another type you don't control? I think it would make more sense to have it pick the best match much like other overloads.</p>
<div class="gmail_quote">On Feb 22, 2012 9:05 PM, "H. S. Teoh" <<a href="mailto:hsteoh@quickfur.ath.cx">hsteoh@quickfur.ath.cx</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Wed, Feb 22, 2012 at 08:51:50PM -0500, Kevin wrote:<br>
> I have the following code which gives the same result on ldc2 and<br>
> dmd. If I compare two objects of different classes I always get<br>
> false even though the comparator is called.<br>
[...]<br>
> The key thing to notice is that opEquals() gets called both times.<br>
> Any ideas about what is happening?<br>
<br>
It's because when A and B are different types, the compiler translates<br>
A==B to:<br>
<br>
A.opEquals(B) && B.opEquals(A)<br>
<br>
Both parties need to agree before they are considered equal.<br>
<br>
<br>
T<br>
<br>
--<br>
Shin: (n.) A device for finding furniture in the dark.<br>
</blockquote></div>