From: Yura Sokolov Date: 2011-12-14T19:03:21+09:00 Subject: [ruby-core:41647] [ruby-trunk - Bug #5752] Array#delete_if side effects due to changeset r32360 Issue #5752 has been updated by Yura Sokolov. File array.c.patch added ---------------------------------------- Bug #5752: Array#delete_if side effects due to changeset r32360 http://redmine.ruby-lang.org/issues/5752 Author: Thomas Leitner Status: Open Priority: Normal Assignee: Category: core Target version: 1.9.3 ruby -v: ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux] It seems that the changeset r32360 introduced another side effect. Here are two IRB sessions, one in ruby-1.9.2-p136 and the other in ruby-1.9.3-p0: ruby-1.9.2-p136 :001 > x = [1,2,3,4,5,6,7,8,9] => [1, 2, 3, 4, 5, 6, 7, 8, 9] ruby-1.9.2-p136 :002 > x.delete_if {|i| i == x[i-1]} => [] ruby-1.9.3-p0 :001 > x = [1,2,3,4,5,6,7,8,9] => [1, 2, 3, 4, 5, 6, 7, 8, 9] ruby-1.9.3-p0 :002 > x.delete_if {|i| i == x[i-1]} => [2, 3, 4, 5, 6, 7, 8, 9] If this is indeed the intended behaviour, it should probably be documented clearly that the array is changed instantly every time the block is called and not after the iteration is over. -- http://redmine.ruby-lang.org