col := #(1 2 3 4 5) asOrderedCollection.
col copy do: [ :each | col remove: each. ].
col

will work instead

Alexandre
-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.



> On Apr 2, 2015, at 3:22 AM, Peter Uhnák <i.uh...@gmail.com> wrote:
> 
> Hi,
> 
> I've just run into quite a nasty surprise
> ~~~~~~~~~~~~~~~~
> col := #(1 2 3 4 5) asOrderedCollection.
> col do: [ :each | col remove: each. ].
> col
> ~~~~~~~~~~~~~~~~
> it throws "NotFound: nil not found in OrderedCollection"
> I tested it also in Pharo3 and there it just silently removed first, third 
> and fifth element.
> 
> Looking at the implementation of OrderedCollection>>do:  it seems that doing 
> what I'm doing is a bad idea.
> 
> So what shall one do:? col copy do: [...] ?
> 
> Why can't do: be a bit smarter? Optimization?
> 
> Thanks,
> Peter


Reply via email to