Re: Wisdom of overriding isEqual:
Re: Wisdom of overriding isEqual:
- Subject: Re: Wisdom of overriding isEqual:
- From: Bill Cheeseman <email@hidden>
- Date: Wed, 10 Mar 2004 20:06:59 -0500
on 2004-03-10 6:59 PM, Ondra Cada at email@hidden wrote:
>
On Thursday, Mar 11, 2004, at 00:26 Europe/Prague, Wade Tregaskis wrote:
>
>
> ...since if the argument is an NSString, it can't be equal to the
>
> receiver, obviously
>
>
Ummm... obviously? I *DO NOT* advocate it is right, but I can well
>
imagine a very sensible design in which, say, an NSAttributedString
>
would be truly "equal" to a NSString of the same contents, attributes
>
ignored...
>
>
I don't want to argue, you are most probably right. Only I wanted to
>
point out that, at least in principle, different classes *may* be equal.
And the other side of that is also true. Things that might ordinarily be
considered equal in some standardized context might not be considered equal
for a particular purpose. The light dawned for me recently, when I realized
that I could make a custom class of mine much more efficient by defining
equality in a very odd way, which happened to work perfectly for the
purposes of the particular class. Basically, it allowed certain tests to be
handled in the -isEqual: method so that I could use the efficiency of
built-in collection class methods that had to honor my peculiar definition
of equality.
In cases like this, if not generally, documentation is extremely important.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.