Austin Ziegler wrote: > On Fri, 29 Aug 2003 22:02:01 +0900, Dan North wrote: > >>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! > > > I wouldn't like that, personally. I don't remember exactly where, but I > believe that I have a piece of code taking advantage of the fact that a > receiver *can* be modified during iteration. I don't modify during a > #collect, but during an #each. One of the things you can do is: > > arr.each { |e| arr << f.flatten if f.kind_of?(Array) } Well, if I understand Matz correctly, this behavior is not guaranteed. If that's the case, you should change this to avoid being bitten the way I was. Hal