Ruby 的 Array#shuffle 中的默认 random: 参数是什么

What is the default random: argument in Ruby's Array#shuffle

Array#shuffle 的文档指出:

shuffle(random: rng) → new_ary

The optional rng argument will be used as the random number generator.

a.shuffle(random: Random.new(1))  #=> [1, 3, 2]

如果我提供可选的random参数,它的用途是什么?

等效地,如果我调用 a.shuffle(random: rng)rng 需要什么才能使其与 a.shuffle 相同?

签名就对了,shuffle(random: Random)。也就是说 random 的默认值是 Random Class object.

The class method Random.rand provides the base functionality of Kernel.rand along with better handling of floating point values. These are both interfaces to the Ruby system PRNG.