ruby-changes:70184
From: Nobuyoshi <ko1@a...>
Date: Mon, 13 Dec 2021 19:58:03 +0900 (JST)
Subject: [ruby-changes:70184] dc490aced3 (master): [DOC] Improve Random::Formatter description and example
https://git.ruby-lang.org/ruby.git/commit/?id=dc490aced3 From dc490aced3fc62d7eaa10d2bfc2211da826ea538 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Mon, 13 Dec 2021 19:54:38 +0900 Subject: [DOC] Improve Random::Formatter description and example --- lib/random/formatter.rb | 2 ++ random.c | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/random/formatter.rb b/lib/random/formatter.rb index c48886f9e04..0e80bd0f70e 100644 --- a/lib/random/formatter.rb +++ b/lib/random/formatter.rb @@ -3,6 +3,8 @@ https://github.com/ruby/ruby/blob/trunk/lib/random/formatter.rb#L3 # == Random number formatter. # +# Formats generated random numbers in many manors. +# # === Examples # # Generate random hexadecimal strings: diff --git a/random.c b/random.c index 580c1f26eb2..32c470bdad7 100644 --- a/random.c +++ b/random.c @@ -1807,7 +1807,14 @@ InitVM_Random(void) https://github.com/ruby/ruby/blob/trunk/random.c#L1807 rb_define_private_method(CLASS_OF(rb_cRandom), "left", random_s_left, 0); { - /* Format raw random number as Random does */ + /* + * Generate a random number in the given range as Random does + * + * prng.random_number #=> 0.5816771641321361 + * prng.random_number(1000) #=> 485 + * prng.rand #=> 0.5816771641321361 + * prng.rand(1000) #=> 485 + */ VALUE m = rb_define_module_under(rb_cRandom, "Formatter"); rb_include_module(base, m); rb_extend_object(base, m); -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/