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

dropFirst(_:)

Omits a specified number of elements from the base asynchronous sequence, then passes through all remaining elements. 指定された数の要素を基底非同期シーケンスから除きます、それから全ての残りの要素をずっと渡します。

Declaration 宣言

func dropFirst(_ count: Int = 1) -> AsyncDropFirstSequence<AsyncThrowingStream<Element, Failure>>

Parameters パラメータ

count

The number of elements to drop from the beginning of the sequence. count must be greater than or equal to zero. このシーケンスの初めの部分から落とす要素の数。countは、ゼロより大きいか等しくなければなりません。

Return Value 戻り値

An asynchronous sequence that drops the first count elements from the base sequence. ある非同期シーケンス、それは最初のcount要素を基底シーケンスから抜かします。

Discussion 解説

Use dropFirst(_:) when you want to drop the first n elements from the base sequence and pass through the remaining elements. dropFirst(_:)を使ってください、あなたが最初のn要素を基底シーケンスから抜かす、そして残っている要素をずっと渡したい場合は。

In this example, an asynchronous sequence called Counter produces Int values from 1 to 10. The dropFirst(_:) method causes the modified sequence to ignore the values 0 through 4, and instead emit 5 through 10: この例において、Counterと呼ばれる非同期シーケンスはInt値を1から10まで生み出します。dropFirst(_:)メソッドは、その修正されたシーケンスに値0から4を無視させます、そして代わりに5から10を放出させます:


for await number in Counter(howHigh: 10).dropFirst(3) {
    print("\(number) ", terminator: " ")
}
// prints "4 5 6 7 8 9 10"

If the number of elements to drop exceeds the number of elements in the sequence, the result is an empty sequence. 取り除く要素の数がシーケンスの要素数を越えるならば、結果は空のシーケンスです。

See Also 参照

Excluding Elements 要素を除外する