Bug #3581
closedArray#combination enumerator ends iteration early
Description
=begin
C:>type big_combination.rb
count = 0
combo = nil
(1..166).to_a.combination(5).each do |c|
count+= 1; combo = c
end
p count, combo
C:>ruby -v big_combination.rb
ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32]
129462338
[5, 34, 54, 73, 81]
The same (incorrect) results are witnessed using 1.9.1p378 on Ubuntu.
The expected result should be:
988455798
[162, 163, 164, 165, 166]
As noted in a ruby-talk thread[1], the correct results were seen on 1.9.1p129
Note that changing "166" to "141" in the above code instead results in the RangeError "in `combination': too big for combination". Perhaps this is the same issue as bug #3089 [ruby-core:29240].
Files
Updated by marcandre (Marc-Andre Lafortune) over 13 years ago
- Category set to core
- Status changed from Open to Rejected
- Assignee set to marcandre (Marc-Andre Lafortune)
=begin
This is already been fixed. Please update your Ruby to either the 1.9.2 rc2 or trunk.
=end