From: "RadosÅ‚aw BuÅ‚at" Date: 2009-02-06T02:10:33+09:00 Subject: Re: Array#choice always produce the same sequence On Thu, Feb 5, 2009 at 2:42 PM, Stefano Crocco wrote: > p [1,2,3,4].choice > > ruby test.rb > => 4 > ruby test.rb > => 4 > ruby test.rb > => 4 > > And so on. If at the beginning of the script I add a call to Kernel#srand > (without arguments), I get the correct behaviour, that is a different number > every time the script is run. It looks like it was fixed in ruby1.9 (notice that #choice has been renamed to #sample): ruby1.9.1 -e "p [1,2,3,4].sample" 4 ruby1.9.1 -e "p [1,2,3,4].sample" 1 ruby1.9.1 -e "p [1,2,3,4].sample" 2 ruby1.9.1 -e "p [1,2,3,4].sample" 3 ruby1.9.1 -e "p [1,2,3,4].sample" 1 ruby1.9.1 -e "p [1,2,3,4].sample" File a bug or ask in ruby-core if it's desired behavior. -- Pozdrawiam Rados³aw Bu³at http://radarek.jogger.pl - mój blog