Project

General

Profile

This project is closed and read-only.

Actions

Backport #929

closed

Array#shuffle does not initialize random seed

Backport #929: Array#shuffle does not initialize random seed

Added by jsc (Justin Collins) over 17 years ago. Updated over 15 years ago.


Description

=begin
Unlike calling Kernel#rand, Array#shuffle and Array#shuffle! do not automatically seed the random number generator. This means subsequent runs of the same program will produce the same shuffles unless a separate call is made to Kernel#rand or Kernel#srand.

For example, running just

ruby -e 'p Array.new(50) {|n| n }.shuffle'

will always give the same output.
=end

Actions

Also available in: PDF Atom