diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-02-24 01:12:51 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-02-24 01:12:51 +0000 |
commit | 623160916dccc23d36bcceaf8014242903c6b04a (patch) | |
tree | b01e7c826d2cd2e576085d900402e4a0a312bdb3 /array.c | |
parent | e5d5cc4a882504b1ab11312bd7c1a1682c5ebf73 (diff) |
Improve Array#sample with random documentation
* array.c (rb_ary_sample): Adds examples for the use of the
optional parameter random for Array#sample and unifies the style
with the documentation of Array#shuffle.
[Fix GH-1825]
From: Alberto Almagro <[email protected]>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -4868,11 +4868,14 @@ rb_ary_shuffle(int argc, VALUE *argv, VALUE ary) * If the array is empty the first form returns +nil+ and the second form * returns an empty array. * - * The optional +rng+ argument will be used as the random number generator. - * * a = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] * a.sample #=> 7 * a.sample(4) #=> [6, 4, 2, 5] + * + * The optional +rng+ argument will be used as the random number generator. + * + * a.sample(random: Random.new(1)) #=> 6 + * a.sample(4, random: Random.new(1)) #=> [6, 10, 9, 2] */ |