Hi,
I need to delete all the instances of a class. I would like to know, wich is the best way to do this.
I'm trying this: IGCompany allInstances do: [ :each | each := nil].
But this, doesn't works.
All help is appreciated.
Cheers.
"Giuseppe" == Giuseppe Luigi Punzi Ruiz glpunzi@lordzealon.com writes:
Giuseppe> I need to delete all the instances of a class. I would like to know, wich is Giuseppe> the best way to do this.
Giuseppe> I'm trying this: Giuseppe> IGCompany allInstances do: [ :each | each := nil].
Giuseppe> But this, doesn't works.
Giuseppe> All help is appreciated.
"each := nil" changes the local variable "each" from containing an instance of IGCompany to holding nil. That doesn't do anything to the original instance.
You need to find all of the objects *holding* these IGCompany instances and tell them to let go. Once everyone has let go of all of them, then the next garbage collection pass will see that nobody is pointing to them, and get rid of them. In normal programming, this should just happen naturally.
The larger question is, why do you care? I hope you're not writing code that looks like "IGCompany allInstances" for *real* code.
Am 14.09.2008 um 20:15 schrieb Giuseppe Luigi Punzi Ruiz:
Hi,
I need to delete all the instances of a class.
Why?
I would like to know, wich is the best way to do this.
I'm trying this: IGCompany allInstances do: [ :each | each := nil].
But this, doesn't works.
There is no need to "delete instances". When they are not used anymore, they will be garbage collected automatically.
- Bert -
beginners@lists.squeakfoundation.org