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

max()

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

Declaration 宣言

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

Return Value 戻り値

The sequence’s maximum 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 max() method returns the max value of the sequence. この例において、Counterと呼ばれる非同期シーケンスはInt値を1から10まで生み出します。max()メソッドは、シーケンスの最大値を返します。


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

See Also 参照

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