So it's undefined behaviour, but "Don't modify the receiver while you 
are iterating over it." :)

Can I suggest the solution that Java uses, which is to fail fast in that 
situation (ConcurrentModificationException). You would not believe how 
much debugging time that one tiny feature has saved me!

Cheers,
Dan

Yukihiro Matsumoto wrote:

>Hi,
>
>In message "Re: #collect with block modifying receiver"
>    on 03/08/29, Hal Fulton <hal9000 / hypermetrics.com> writes:
>
>|OK, so this *really* makes me wonder what the "theoretically correct"
>|behavior is.
>
>|Matz, are you listening?? Enlighten us, please...
>
>Ah, listen, it's undefined behavior. ;-)
>
>To be serious, I don't want to slow down performance by defining any
>exact behavior.  Don't modify the receiver while you are iterating
>over it.
>
>							matz.
> 
>  
>
--
Dan North
http://www.thoughtworks.com