зеркало из https://github.com/github/ruby.git
array.rb: show examples whether `Array#shuffle!` has side effect or not
Partially revert 54fb8fb62a
This commit is contained in:
Родитель
fa3670e6e4
Коммит
a02ba60466
6
array.rb
6
array.rb
|
@ -4,7 +4,8 @@ class Array
|
||||||
#
|
#
|
||||||
# Shuffles the elements of +self+ in place.
|
# Shuffles the elements of +self+ in place.
|
||||||
# a = [1, 2, 3] #=> [1, 2, 3]
|
# 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:
|
# The optional +random+ argument will be used as the random number generator:
|
||||||
# a.shuffle!(random: Random.new(1)) #=> [1, 3, 2]
|
# a.shuffle!(random: Random.new(1)) #=> [1, 3, 2]
|
||||||
|
@ -17,7 +18,8 @@ class Array
|
||||||
#
|
#
|
||||||
# Returns a new array with elements of +self+ shuffled.
|
# Returns a new array with elements of +self+ shuffled.
|
||||||
# a = [1, 2, 3] #=> [1, 2, 3]
|
# 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:
|
# The optional +random+ argument will be used as the random number generator:
|
||||||
# a.shuffle(random: Random.new(1)) #=> [1, 3, 2]
|
# a.shuffle(random: Random.new(1)) #=> [1, 3, 2]
|
||||||
|
|
Загрузка…
Ссылка в новой задаче