[Newbies] Re: How to empty a collection?

Klaus D. Witzel klaus.witzel at cobss.com
Tue Feb 19 20:12:27 UTC 2008

On Tue, 19 Feb 2008 21:01:14 +0100, nicolas cellier wrote:

> cdrick a écrit :
>>  or again
>> removeAll: aCollection
>> 	aCollection == self
>>                 ifTrue: [self removeAll: aCollection copy]
>>                 ifFalse: [aCollection do: [:each | self remove: each]].
>>  Or maybe, if aCollection == self, a warning could be raised ?
>>  What do you think ?
>>  Cédrick
> aCollection == self is not the only case that can fail.
> Imagine i pass a wrapper collection on self, like a MappedCollection.
> When i will change self with remove:, i will also change the argument  
> which is just a wrapper on self.
> Hope my explanations are not too much confusing...

Let's see: "Remove each element of aCollection from the receiver. If  
successful for each, answer aCollection. Otherwise create an error  

What mapping would *not* raise the error notification ;-)

BTW: MappedCollection does not exist in sq3.10-7159dev08.02.1.image ...


> Nicolas

More information about the Beginners mailing list