help!!

Mike Klein mike at twinsun.com
Wed Apr 15 02:42:36 UTC 1998


> today's puzzle is:
> 
>     Dictionary new
>         at: (Set with: 1) put: 'is';
>         at: (Set new add: 1; yourself) ifAbsent: ['isnot']
> 
> why does this little snippet *sometimes* answer 'is' and *sometimes* answers
> 'isnot'?

Because whomever implemented #= for Sets forgot to re-implement hash
to maintain the invariant:

Objects that are = MUST have the same hash.
For a quick, yet inefficient solution, implement
Set>>#hash as

hash
	^self size
	


-- Mike Klein





More information about the Squeak-dev mailing list