2006/6/29, Phillip Hutchings <sitharus / sitharus.com>: > 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. Personally I wouldn't rely on this behavior though. Changing a collection while iterating it often leads to undefined behavior. Personally I'd rather choose an approach that either copies the collection or defers the changes to after the iteration. Alternatively with an array iterate explicitely with for and using an array index. ar = ar.inject([]) {|copy, el| case x when "add" then copy << el << "bar" when "remove" then copy else copy << el end end Kind regards robert -- Have a look: http://www.flickr.com/photos/fussel-foto/