Instance Method インスタンスメソッド

min()

Returns the minimum element in an asynchronous sequence of comparable elements. 比較可能要素それらからなるある非同期シーケンスの中の最小の要素を返します。

Declaration 宣言

@warn_unqualified_access func min() async rethrows -> ChildTaskResult?
Available when ChildTaskResult conforms to Comparable. ChildTaskResultComparableに準拠する時に利用可能です。

Return Value 戻り値

The sequence’s minimum element. If the sequence has no elements, returns nil. シーケンスの最小の要素。シーケンスが要素を持たないならば、nilを返します。

Discussion 解説

In this example, an asynchronous sequence called Counter produces Int values from 1 to 10. The min() method returns the minimum value of the sequence. この例において、Counterと呼ばれる非同期シーケンスはInt値を1から10まで生み出します。min()メソッドは、シーケンスの最小値を返します。


let min = await Counter(howHigh: 10)
    .min()
print(min ?? "none")
// Prints: 1

See Also 参照

Accessing an Asynchronous Sequence of Results 結果それらからなるある非同期シーケンスにアクセスする