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

ruby-changes:62798

From: Jeremy <ko1@a...>
Date: Wed, 2 Sep 2020 02:53:02 +0900 (JST)
Subject: [ruby-changes:62798] de10a1f358 (master): Update documentation for Range#max

https://git.ruby-lang.org/ruby.git/commit/?id=de10a1f358

From de10a1f3583adeeffd7f8bcf8f276e0a626ffa0c Mon Sep 17 00:00:00 2001
From: Jeremy Evans <code@j...>
Date: Tue, 1 Sep 2020 09:58:45 -0700
Subject: Update documentation for Range#max


diff --git a/range.c b/range.c
index 5e1103c..59d8aef 100644
--- a/range.c
+++ b/range.c
@@ -1200,14 +1200,34 @@ range_min(int argc, VALUE *argv, VALUE range) https://github.com/ruby/ruby/blob/trunk/range.c#L1200
  *     rng.max(n)                    -> obj
  *     rng.max(n) {| a,b | block }   -> obj
  *
- *  Returns the maximum value in the range. Returns +nil+ if the begin
- *  value of the range larger than the end value. Returns +nil+ if
- *  the begin value of an exclusive range is equal to the end value.
- *
- *  Can be given an optional block to override the default comparison
- *  method <code>a <=> b</code>.
- *
- *    (10..20).max    #=> 20
+ *  Returns the maximum value in the range, or an array of maximum
+ *  values in the range if given an \Integer argument.
+ *
+ *  For inclusive ranges with an end, the maximum value of the range
+ *  is the same as the end of the range.
+ *
+ *  If an argument or block is given, or +self+ is an exclusive,
+ *  non-numeric range, calls Enumerable#max (via +super+) with the
+ *  argument and/or block to get the maximum values, unless +self+ is
+ *  a beginless range, in which case it raises a RangeError.
+ *
+ *  If +self+ is an exclusive, integer range (both start and end of the
+ *  range are integers), and no arguments or block are provided, returns
+ *  last value in the range (1 before the end).  Otherwise, if +self+ is
+ *  an exclusive, numeric range, raises a TypeError.
+ * 
+ *  Returns +nil+ if the begin value of the range larger than the
+ *  end value. Returns +nil+ if the begin value of an exclusive
+ *  range is equal to the end value.  Raises a RangeError if called on
+ *  an endless range.
+ *
+ *  Examples:
+ *    (10..20).max                        #=> 20
+ *    (10..20).max(2)                     #=> [20, 19]
+ *    (10...20).max                       #=> 19
+ *    (10...20).max(2)                    #=> [19, 18]
+ *    (10...20).max{|x, y| -x <=> -y }    #=> 10
+ *    (10...20).max(2){|x, y| -x <=> -y } #=> [10, 11]
  */
 
 static VALUE
-- 
cgit v0.10.2


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

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