From: Arthur Gunn Date: 2011-01-14T15:49:25+09:00 Subject: [ruby-core:34492] [Ruby 1.9-Feature#4247] New features for Array#sample, Array#choice Issue #4247 has been updated by Arthur Gunn. Like Benoit said, Array#choice does sound like it would return only one element, I very much like the proposal of: p [1, 2, 3].sample(5, repeat: true) #=> [2, 2, 3, 1, 3] I don't think the distinction between #sample and #samples is obvious enough, the naming suggests #sample would return one element, and #samples many, not that the latter is an iterator. #each_sample is a little ugly, but much more self-explanatory I think. How important is it to have something like #each_sample though? Personally, I would probably always do something like this: [1, 2, 3, 4, 5].sample(3).each { |n| puts n } ---------------------------------------- http://redmine.ruby-lang.org/issues/show/4247 ---------------------------------------- http://redmine.ruby-lang.org