Set an mutable objects

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Set an mutable objects

Damien Cassou-3
Hi,

I redefined #= and #hash in one of my classes. Objects from this class
are mutable and the hash value change when this objects change. It seems
  wrong to store mutable objects like this in a set but I can't find any
documentation about this anywhere. Because when you add such an object
into one Set and change the object, then the set won't find your object
using #includes: anymore.

What is allowed and what is not please ?


Thank you

Reply | Threaded
Open this post in threaded view
|

RE: Set an mutable objects

Ron Teitelbaum
Damien,

Set>>rehash should fix your #includes: problem.  I won't start the argument
about the virtues of redefining #= except to say that you must redefine
#hash also, so since you have the rest is up to you!

Ron Teitelbaum

> -----Original Message-----
> From: [hidden email] [mailto:squeak-dev-
> [hidden email]] On Behalf Of Damien Cassou
> Sent: Tuesday, August 15, 2006 11:04 AM
> To: The general-purpose Squeak developers list
> Subject: Set an mutable objects
>
> Hi,
>
> I redefined #= and #hash in one of my classes. Objects from this class
> are mutable and the hash value change when this objects change. It seems
>   wrong to store mutable objects like this in a set but I can't find any
> documentation about this anywhere. Because when you add such an object
> into one Set and change the object, then the set won't find your object
> using #includes: anymore.
>
> What is allowed and what is not please ?
>
>
> Thank you
>



Reply | Threaded
Open this post in threaded view
|

Re: Set an mutable objects

Damien Cassou-3
Ron Teitelbaum wrote:
> Damien,
>
> Set>>rehash should fix your #includes: problem.  I won't start the argument
> about the virtues of redefining #= except to say that you must redefine
> #hash also, so since you have the rest is up to you!


Thank you for this solution