[BUG]Collection>>removeAll:

Richard A. O'Keefe ok at cs.otago.ac.nz
Mon Aug 19 22:17:30 UTC 2002


I proposed this fix to Collection>>removeAll:
    removeAll: aCollection
	|c|

	(c := aCollection) == self ifTrue: [c := c copy].
	c do: [:each | self remove: each].
	^c

Ian Piumarta <ian.piumarta at inria.fr> wrote:
	Being a bear of little brain I'm probably missing something fundamental
	here, but... 	...what's wrong with
	
		aCollection == self ifTrue: [^self species new].
	
The fact that it doesn't actually REMOVE anything from the receiver.

Remember, #removeAll: does not return the receiver, the thing that has
had the elements removed, it is supposed to modify the receiver and
return the collection of elements that went away.

The goal is that
    a := #(1 2 3 4) asOrderedCollection.
    a removeAll: a
should have the *same* effect on a as
    b := #(1 2 3 4)
    a := b asOrderedCollection.
    a removeAll: b




More information about the Squeak-dev mailing list