File tree 1 file changed +15
-6
lines changed
1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -527,14 +527,23 @@ nil を返します。引数を指定する形式では、空の配列を返し
527
527
#@end
528
528
529
529
#@since 2.7.0
530
- --- minmax -> [obj, obj ]
531
- --- minmax {| a,b | block } -> [obj, obj ]
530
+ --- minmax -> [object, object ]
531
+ --- minmax {|a, b| ... } -> [object, object ]
532
532
533
- Returns a two element array which contains the minimum and the maximum
534
- value in the range.
533
+ 範囲内の要素のうち、最小の要素と最大の要素を要素とするサイズ 2 の配列を返します。
534
+
535
+ 一つ目の形式では、全要素が互いに <=> メソッドで比較できることを仮定しています。
536
+
537
+ 二つ目の形式では、要素同士の比較をブロックを用いて行います。
538
+ ブロックの値は、a > b のとき正、 a == b のとき 0、a < b のとき負の整数を、期待しています。
539
+
540
+ 例:
541
+
542
+ (1..3).minmax # => [1, 3]
543
+
544
+ h = { 1 => "C", 2 => "Go", 3 => "Ruby" }
545
+ (1..3).minmax { |a, b| h[a].length <=> h[b].length } # => [1, 3]
535
546
536
- Can be given an optional block to override the default comparison method
537
- `a <=> b`.
538
547
#@end
539
548
540
549
--- max -> object | nil
You can’t perform that action at this time.
0 commit comments