Skip to content

Instantly share code, notes, and snippets.

@benedikt
Created October 23, 2013 09:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benedikt/7115437 to your computer and use it in GitHub Desktop.
Save benedikt/7115437 to your computer and use it in GitHub Desktop.
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