ruby-changes:70329
From: Chris <ko1@a...>
Date: Mon, 20 Dec 2021 01:10:35 +0900 (JST)
Subject: [ruby-changes:70329] 1dd10e1892 (master): [DOC] Add documentation for Random.rand and Random.seed
https://git.ruby-lang.org/ruby.git/commit/?id=1dd10e1892 From 1dd10e189274546689c0b59f6a76849b2808f255 Mon Sep 17 00:00:00 2001 From: Chris AtLee <chris.atlee@s...> Date: Tue, 9 Nov 2021 09:57:23 -0500 Subject: [DOC] Add documentation for Random.rand and Random.seed --- random.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/random.c b/random.c index bf9479168bf..f3dec5cca20 100644 --- a/random.c +++ b/random.c @@ -1293,6 +1293,21 @@ random_s_bytes(VALUE obj, VALUE len) https://github.com/ruby/ruby/blob/trunk/random.c#L1293 return rand_bytes(&random_mt_if, rnd, NUM2LONG(rb_to_int(len))); } +/* + * call-seq: Random.seed -> integer + * + * Returns the seed value used to initialize the Ruby system PRNG. + * This may be used to initialize another generator with the same + * state at a later time, causing it to produce the same sequence of + * numbers. + * + * Random.seed #=> 1234 + * prng1 = Random.new(Random.seed) + * prng1.seed #=> 1234 + * prng1.rand(100) #=> 47 + * Random.seed #=> 1234 + * Random.rand(100) #=> 47 + */ static VALUE random_s_seed(VALUE obj) { @@ -1646,10 +1661,10 @@ rb_f_rand(int argc, VALUE *argv, VALUE obj) https://github.com/ruby/ruby/blob/trunk/random.c#L1661 * Random.rand(max) -> number * Random.rand(range) -> number * - * Generates a random number by the default PRNG. - * See Random#rand. + * Returns a random number using the Ruby system PRNG. + * + * See also Random#rand. */ - static VALUE random_s_rand(int argc, VALUE *argv, VALUE obj) { -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/