random ruby array code example
Example 1: ruby array randomly display
arr = [1, 2, 3, 4]
arr.sample # => 3 pick random number
arr.shuffle # => [3, 1, 4, 2]
Example 2: ruby randomize array
[1,2,3,4].shuffle => [2, 1, 3, 4]
[1,2,3,4].shuffle => [1, 3, 2, 4]