Why does Object.opEquals *exist*
Bill Baxter
dnewsgroup at billbaxter.com
Wed Nov 8 19:09:01 PST 2006
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
More information about the Digitalmars-d
mailing list