@@ -825,6 +825,51 @@ class Range[out Elem] < Object
825825 #
826826 def min : ...
827827
828+ # <!--
829+ # rdoc-file=range.c
830+ # - minmax -> [object, object]
831+ # - minmax {|a, b| ... } -> [object, object]
832+ # -->
833+ # Returns a 2-element array containing the minimum and maximum value in `self`,
834+ # either according to comparison method `#<=>` or a given block.
835+ #
836+ # With no block given, returns the minimum and maximum values, using `#<=>` for
837+ # comparison:
838+ #
839+ # (1..4).minmax # => [1, 4]
840+ # (1...4).minmax # => [1, 3]
841+ # ('a'..'d').minmax # => ["a", "d"]
842+ # (-4..-1).minmax # => [-4, -1]
843+ #
844+ # With a block given, the block must return an integer:
845+ #
846+ # * Negative if `a` is smaller than `b`.
847+ # * Zero if `a` and `b` are equal.
848+ # * Positive if `a` is larger than `b`.
849+ #
850+ # The block is called `self.size` times to compare elements; returns a 2-element
851+ # Array containing the minimum and maximum values from `self`, per the block:
852+ #
853+ # (1..4).minmax {|a, b| -(a <=> b) } # => [4, 1]
854+ #
855+ # Returns `[nil, nil]` if:
856+ #
857+ # * The begin value of the range is larger than the end value:
858+ #
859+ # (4..1).minmax # => [nil, nil]
860+ # (4..1).minmax {|a, b| -(a <=> b) } # => [nil, nil]
861+ #
862+ # * The begin value of an exclusive range is equal to the end value:
863+ #
864+ # (1...1).minmax # => [nil, nil]
865+ # (1...1).minmax {|a, b| -(a <=> b) } # => [nil, nil]
866+ #
867+ # Raises an exception if `self` is a beginless or an endless range.
868+ #
869+ # Related: Range#min, Range#max.
870+ #
871+ def minmax : ...
872+
828873 # <!--
829874 # rdoc-file=range.c
830875 # - overlap?(range) -> true or false
0 commit comments