Skip to content

Commit

Permalink
array.rb: show examples whether Array#shuffle! has side effect or not
Browse files Browse the repository at this point in the history
Partially revert 54fb8fb
  • Loading branch information
mame committed Nov 12, 2020
1 parent fa3670e commit a02ba60
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ class Array
#
# Shuffles the elements of +self+ in place.
# a = [1, 2, 3] #=> [1, 2, 3]
# a.shuffle! #=> [2, 3, 1]
# 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]
Expand All @@ -17,7 +18,8 @@ def shuffle!(random: Random)
#
# Returns a new array with elements of +self+ shuffled.
# a = [1, 2, 3] #=> [1, 2, 3]
# a.shuffle #=> [2, 3, 1]
# a.shuffle #=> [2, 3, 1]
# a #=> [1, 2, 3]
#
# The optional +random+ argument will be used as the random number generator:
# a.shuffle(random: Random.new(1)) #=> [1, 3, 2]
Expand Down

0 comments on commit a02ba60

Please sign in to comment.