From: Gavin Kistner Date: 2010-07-17T04:52:28+09:00 Subject: [ruby-core:31318] [Bug #3581] Array#combination enumerator ends iteration early Bug #3581: Array#combination enumerator ends iteration early http://redmine.ruby-lang.org/issues/show/3581 Author: Gavin Kistner Status: Open, Priority: Normal ruby -v: ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32] 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]. [1] http://groups.google.com/group/comp.lang.ruby/browse_frm/thread/c558332ff0a053ad/67e87e76d289889e#67e87e76d289889e ---------------------------------------- http://redmine.ruby-lang.org