From: Robert Klemme Date: 2012-06-26T01:23:51+09:00 Subject: Re: Array#sample is Set#sample and not Array#sample ! On Mon, Jun 25, 2012 at 4:53 PM, Michel Demazure wrote: > Arrays are ordered, sets are not. Sampling an array should give random > elements in the good order. But : > > irb(main):001:0> (0..10).to_a.sample(5) > => [8, 10, 4, 6, 7] Where is the problem with that? What do you mean by "good order"? > Today's Array#sample actually is Set#sample, but Set#sample does not > exist. > > irb(main):002:0> Set.new((0..10)).sample(5) > NoMethodError: undefined method `sample' for # 6, 7, 8, 9, 10}> I am sorry, I don't get it. Can you explain what your expectation is? Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/