[Newbies] reimplementing #= and #hash

Oscar Nierstrasz oscar.nierstrasz at gmail.com
Sun Sep 23 09:27:41 UTC 2007

Hi Ching,

#hash should be reimplemented to make sure that objects considered to  
be equal will end up in the same hash bucket.

The usual trick is to take a bitXor of the hashes of the instance  

	^ member hash bitXor: processor hash

Hope that helps.

On Sep 23, 2007, at 9:52, Ching de la Serna wrote:

> Hi List,
> I have a Class PoolQueue which has instvars 'member' and  
> 'processor'. I find that an instance of PoolQueue when placed in an  
> OrderedCollection can no longer be considered equal. I suppose I  
> have to reimplement #= and #hash to allow PoolQueue instances to be  
> compared.
> My problem: how do I implement #hash? Or stated another way, what  
> does #hash accomplish?
> Thanks in advance.
> Ching.
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

More information about the Beginners mailing list