[Newbies] How to empty a collection?

Bert Freudenberg bert at freudenbergs.de
Tue Feb 19 10:08:07 UTC 2008


On Feb 19, 2008, at 10:53 , Marcin Tustin wrote:

> Re-initialize how? I can't see a way to run object initialisation  
> over again on an existing object.


Everything in Smalltalk happens by sending a message. How was your  
object initialized? By sending a message. How can you initialize it  
again? Send the message again.

Case in point - OrderedCollection. How is it initialized? Look at  
#new:. It sends #setCollection:. So send #setCollection: with a new  
Array and you're done.

Well, of course you're not *supposed* to be doing this. But you  
could, and it would only be half-evil ;)

- Bert -




More information about the Beginners mailing list