[前][次][番号順一覧][スレッド一覧]

ruby-changes:50435

From: nobu <ko1@a...>
Date: Sat, 24 Feb 2018 10:12:54 +0900 (JST)
Subject: [ruby-changes:50435] nobu:r62553 (trunk): Improve Array#sample with random documentation

nobu	2018-02-24 10:12:51 +0900 (Sat, 24 Feb 2018)

  New Revision: 62553

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62553

  Log:
    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 <alberto.almagro@r...>

  Modified files:
    trunk/array.c
Index: array.c
===================================================================
--- array.c	(revision 62552)
+++ array.c	(revision 62553)
@@ -4868,11 +4868,14 @@ rb_ary_shuffle(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/array.c#L4868
  *  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]
  */
 
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]