[Newbies] Re: How to empty a collection?
ncellier at ifrance.com
Tue Feb 19 20:01:14 UTC 2008
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 ?
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...
More information about the Beginners