> On 18 Feb 2015, at 18:13, Cameron Sanders via Pharo-users 
> <pharo-users@lists.pharo.org> wrote:
> 
> 
> Date: 18 Feb 2015 18:12:33 CET
> Subject: i feel dumb / Pharo3 > OrderedCollection >> do:
> From: Cameron Sanders <camsand...@aol.com>
> To: Any question about pharo is welcome <pharo-users@lists.pharo.org>
> 
> 
> I must be making some silly error here that i cannot see clearly. Why does 
> the following leave anything in the list 'a'? Run it in a workspace. With or 
> without the shallowCopy, i am left with a list with half of the elements in 
> it. Always half.
> 
> This version of Pharo3 (21.0) was downloaded last week. I am running on a Mac.
> 
> Thanks in advance. ... Maybe I just need more coffee.
> -Cam
> 
> | a  |
> a := {  #a. #b. #c. #d. } asOrderedCollection.
> a shallowCopy do: [ :item | (a includes: item) ifTrue: [ a remove: item ]].
> a size
> 

shallowCopy is not enough… OrderedCollection is made up of an internal array.

#copy does the right thing, just copies the array:

postCopy
        array := array copy

and for Array, copy is a shallowCopy.

        Marcus



Reply via email to