Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
In Rubinius, the `Array#each` method does not enumerate elements that are added while enumerating. Is this intentional or a bug?
array = [1, 2]
array.each { |n| array << n * 2; break if n > 10 }
array
# ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
# => [1, 2, 2, 4, 4, 8, 8, 16, 16, 32]
# rubinius 2.1.1 (2.1.0 be67ed17 2013-10-18 JI) [x86_64-darwin12.5.0]
# => [1, 2, 2, 4]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.