summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authorBurdette Lamar <[email protected]>2024-10-04 12:34:11 -0500
committerGitHub <[email protected]>2024-10-04 17:34:11 +0000
commit95ad0e5f85ed5c46367cb61dfcb01978925a225e (patch)
treec3f055e9f372c5c3ca5411affe64eb7788d6dcad /array.c
parent5a95a6905875594bb434d25d3db131d6fc2432ee (diff)
[DOC] Tweaks for Array#minmax (#11787)
Notes
Notes: Merged-By: peterzhu2118 <[email protected]>
Diffstat (limited to 'array.c')
-rw-r--r--array.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/array.c b/array.c
index c79bae6e8e..cc1f927b0e 100644
--- a/array.c
+++ b/array.c
@@ -6181,26 +6181,25 @@ rb_ary_min(int argc, VALUE *argv, VALUE ary)
/*
* call-seq:
- * array.minmax -> [min_val, max_val]
- * array.minmax {|a, b| ... } -> [min_val, max_val]
+ * minmax -> array
+ * minmax {|a, b| ... } -> array
*
- * Returns a new 2-element +Array+ containing the minimum and maximum values
- * from +self+, either per method <tt>#<=></tt> or per a given block:.
+ * Returns a 2-element array containing the minimum-valued and maximum-valued
+ * elements from +self+;
+ * does not modify +self+.
*
- * When no block is given, each element in +self+ must respond to method <tt>#<=></tt>
- * with an Integer;
- * returns a new 2-element +Array+ containing the minimum and maximum values
- * from +self+, per method <tt>#<=></tt>:
+ * With no block given, the minimum and maximum values are determined using method <tt>#<=></tt>:
*
- * [0, 1, 2].minmax # => [0, 2]
+ * [1, 0, 3, 2].minmax # => [0, 3]
*
- * When a block is given, the block must return an Integer;
- * the block is called <tt>self.size-1</tt> times to compare elements;
- * returns a new 2-element +Array+ containing the minimum and maximum values
- * from +self+, per the block:
+ * With a block given, the block must return a numeric;
+ * the block is called <tt>self.size - 1</tt> times to compare elements;
+ * returns the elements having the minimum and maximum values per the block:
*
- * ['0', '00', '000'].minmax {|a, b| a.size <=> b.size } # => ["0", "000"]
+ * ['0', '', '000', '00'].minmax {|a, b| a.size <=> b.size }
+ * # => ["", "000"]
*
+ * Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
*/
static VALUE
rb_ary_minmax(VALUE ary)