[Newbies] Collection>>Includes:...
stéphane ducasse
ducasse at iam.unibe.ch
Mon Aug 7 13:08:44 UTC 2006
Hi florent
Read K. Beck idiom on redefining = normally you MUST also redefine hash
the pattern Kent suggested was
Book>>= anBook
(self author = anBook author ) and: [self name = anBook name]
Book>>hash
self author hash bitXor: self name hash
Now most of the time I try to use sortedCollection to avoid to have
to fix the equality of an object,
SortedCollection sortBlock: [:a :b | a name > b name and.....]
On 5 août 06, at 12:56, florent trolat wrote:
> Mathieu a écrit :
>> florent trolat a écrit :
>>
>>> Hi,
>>>
>>> I've define an '=' message for an oject and I want to use this
>>> object in
>>> a Collection.
>>>
>>> I've seen that 'incudes:' message use '=' or not '==' and it's
>>> not fun
>>> for me!
>>>
>>> I think that '=' message is to compare two objects and '==' to
>>> know if the two object are one!
>>>
>>> So for me 'includes:' must use '==' or not '='...
>>>
>>> May be I have not understand something...
>>>
>>> Thanks to help me....
>>>
>>
>> Hi florent
>>
>> You can do
>>
>> ***********
>> = anObject
>>
>> ^anObject == self
>>
>> ***********
>>
>> But it is not pretty so the best way is to remove = and the default
>> behavior of = is == (unless inherit from someone else...).
>>
> Ok I understand ... it was my job to see this, sorry...
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
More information about the Beginners
mailing list