Ruby 1.9.3 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > Arrayクラス > shuffle!

instance method Array#shuffle!

shuffle! -> self
shuffle!(random: rng) -> self

配列を破壊的にランダムシャッフルします。

引数に Random オブジェクトを渡すことでそのオブジェクトが 生成する疑似乱数列を用いることができます。

例:

a = [ 1, 2, 3 ]           #=> [1, 2, 3]
a.shuffle!                #=> [2, 3, 1]
a                         #=> [2, 3, 1]

[SEE_ALSO] Array#shuffle

class Array