Why does Object.opEquals *exist*
Kristian Kilpi
kjkilpi at gmail.com
Thu Nov 9 03:16:14 PST 2006
On Thu, 09 Nov 2006 06:09:55 +0200, Hasan Aljudy <hasan.aljudy at gmail.com>
wrote:
>
>
> Bill Baxter wrote:
>> Bill Baxter wrote:
>>> Object.opEquals returns int for some reason. That means I can't do
>>> something like:
>>>
>>> bool func() {
>>> ...
>>> return objA == objB;
>>> }
>>>
>>> (Because int can't be converted to bool automatically). Instead I have
>>> to do something like
>>>
>>> return (objA == objB)!=0;
>>>
>>> Which is just looks silly.
>>>
>>> Is there any good reason for opEquals to return an int? opCmp has to,
>>> I understand, but opEquals has no business returning int. Is this a
>>> holdover from the days before bool?
>>>
>>> --bb
>> After seeing some crashes upon comparing with null objects, I realized
>> what I actually want is:
>> return objA is objB;
>> So I should change my question to "Why is opEqual defined by object at
>> all??"
>> --bb
>
> The "is" operator just compares for references/pointers, not object
> equality.
So the original question remains: why 'opEquals' returns int?
More information about the Digitalmars-d
mailing list