[Newbies] reimplementing #= and #hash
Ching de la Serna
ching.dls at gmail.com
Mon Sep 24 00:40:13 UTC 2007
Thanks for your help. Your code makes it clear.
On 9/23/07, Janko Mivšek <janko.mivsek at eranova.si> wrote:
> Hi Ching,
> #= is test for equality while #== is test for identity. What do you
> probably want is to override #= to compare two PoolQueues if they are
> equal or not. But what "equal" means in your case is on you to define.
> Maybe something like this:
> PoolQueue>>= anotherPoolQueue
> ^(self member = anotherPoolQueue member)
> and: [self processor = anotherPoolQueue member]
> But be sure that also member and processor instvars understand #= in a
> correct way. All numbers, strings, symbols etc. understand equality as
> I hope this helps a bit.
> 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.
> Janko Mivšek
> Smalltalk Web Application Server
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners