Actions
Bug #1117
closedArray#choice always produces the same sequence
Description
=begin
In ruby 1.8.7-p72, Array#choice produces the same sequence of elements every time the script is run. For example:
ruby -e 'p [1,2,3,4].choice'
=> 4
ruby -e 'p [1,2,3,4].choice'
=> 4
ruby -e 'p [1,2,3,4].choice'
=> 4
ruby -e 'p [1,2,3,4].choice'
=> 4
According to the documentation, I'd expect this to give a different result every time. To achieve the result I expect, I need to call Kernel#srand before Array#choice:
ruby -e 'srand; p [1,2,3,4].choice'
=> 4
ruby -e 'p [1,2,3,4].choice'
=> 2
ruby -e 'p [1,2,3,4].choice'
=> 3
ruby -e 'p [1,2,3,4].choice'
=> 2
=end
Actions
Like0
Like0Like0Like0Like0