On Thu, Feb 5, 2009 at 2:42 PM, Stefano Crocco <> wr=
ote:
> p [1,2,3,4].choice
>
> ruby test.rb
> =3D> 4
> ruby test.rb
> =3D> 4
> ruby test.rb
> =3D> 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 num=
ber
> 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.
--=20
Pozdrawiam
Rados=B3aw Bu=B3at
http://radarek.jogger.pl - m=F3j blog