On Tue, 19 Feb 2008 16:06:50 +0100, cdrick wrote:

...
I forgot that in my first attemp (and I knew that !)...

col := #(1 2 3) asOrderedCollection.
col  removeAll: col.
^col   returns an OrderedCollection(2)

col  removeAll: col copy is ok.

So, following Bert suggestion, would it be possible to change removeAll: from...

removeAll: aCollection
        aCollection do: [:each | self remove: each].
        ^ aCollection
to

removeAll: aCollection
        aCollection copy do: [:each | self remove: each].
        ^ aCollection
or

removeAll: aCollection
        aCollection == self
                ifTrue: [aCollection copy do: [:each | self remove: each]]
                ifFalse: [aCollection do: [:each | self remove: each]].
        ^ aCollection

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 ?

Thumbs down, I do not want anybody copy a collection behind my back (however small or large it is) just because remove* has nothing to do with copy.

Cédrick


_______________________________________________
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners

Reply via email to