From: Phillip Hutchings Date: 2006-06-29T13:54:22+09:00 Subject: Re: Changes to x within x.each() On 6/29/06, Jim V. Tess wrote: > Does Ruby have defined behavior for 'each' in the following: > > x.each do |obj| > ... > x.change() # This may add or remove objects from x > end > > Cases: > 1) Adding or removing objects 'before' obj. > 2) Adding or removing objects 'after' obj. > > I'm primarily interested when x is an array. From experience Ruby keeps an array index to do each, so if something inserted after obj it'll work, but something before will cause each to get obj twice. -- Phillip Hutchings http://www.sitharus.com/