Ruby Newbie homepage Ruby Newbie homepage

How to use

Quick guide

Official content
Shuffles the elements of self in place.
a = [1, 2, 3] #=> [1, 2, 3]
a.shuffle!    #=> [2, 3, 1]
a             #=> [2, 3, 1]
The optional random argument will be used as the random number generator:
a.shuffle!(random: Random.new(1))  #=> [1, 3, 2]
 
               # File array.rb, line 12
def shuffle!(random: Random)
  Primitive.rb_ary_shuffle_bang(random)
end
            

Was this page useful?