Skip to content

Commit d6f9436

Browse files
authored
Merge pull request #2344 from nekoTheShadow/fix_range_minmax
Range#minmaxの記述を日本語化した
2 parents f7fa158 + ce73025 commit d6f9436

File tree

1 file changed

+15
-6
lines changed
  • refm/api/src/_builtin

1 file changed

+15
-6
lines changed

refm/api/src/_builtin/Range

+15-6
Original file line numberDiff line numberDiff line change
@@ -527,14 +527,23 @@ nil を返します。引数を指定する形式では、空の配列を返し
527527
#@end
528528

529529
#@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]
532532

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]
535546

536-
Can be given an optional block to override the default comparison method
537-
`a <=> b`.
538547
#@end
539548

540549
--- max -> object | nil

0 commit comments

Comments
 (0)