實例方法
drop
dropFirst(_:)
從基本異步序列中省略指定數量的元素,然後傳遞所有剩餘元素。
聲明
func dropFirst(_ count: Int = 1) -> AsyncDropFirstSequence<Self>
返回值
從基本序列中刪除第一個 count 元素的異步序列。
參數
count從序列開頭刪除的元素數。
count必須大於或等於零。
詳述
當您想從基本序列中刪除第一個 n 元素並通過其餘元素時,請使用 dropFirst(_:)。
在此示例中,名為 Counter 的異步序列生成從 1 到 10 的 Int 值。 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"
如果要刪除的元素數超過序列中的元素數,則結果為空序列。
可用版本
iOS 13.0+, iPadOS 13.0+, macOS 10.15+, Mac Catalyst 13.0+, tvOS 13.0+, watchOS 6.0+
相關用法
- Swift AsyncThrowingDropWhileSequence drop(while:)用法及代碼示例
- Swift AsyncThrowingDropWhileSequence first(where:)用法及代碼示例
- Swift AsyncThrowingDropWhileSequence flatMap(_:)用法及代碼示例
- Swift AsyncThrowingDropWhileSequence allSatisfy(_:)用法及代碼示例
- Swift AsyncThrowingDropWhileSequence max()用法及代碼示例
- Swift AsyncThrowingDropWhileSequence contains(_:)用法及代碼示例
- Swift AsyncThrowingDropWhileSequence min()用法及代碼示例
- Swift AsyncThrowingDropWhileSequence prefix(_:)用法及代碼示例
- Swift AsyncThrowingDropWhileSequence max(by:)用法及代碼示例
- Swift AsyncThrowingDropWhileSequence compactMap(_:)用法及代碼示例
- Swift AsyncThrowingDropWhileSequence reduce(_:_:)用法及代碼示例
- Swift AsyncThrowingDropWhileSequence filter(_:)用法及代碼示例
- Swift AsyncThrowingDropWhileSequence prefix(while:)用法及代碼示例
- Swift AsyncThrowingDropWhileSequence map(_:)用法及代碼示例
- Swift AsyncThrowingDropWhileSequence contains(where:)用法及代碼示例
- Swift AsyncThrowingDropWhileSequence min(by:)用法及代碼示例
- Swift AsyncThrowingFlatMapSequence min()用法及代碼示例
- Swift AsyncThrowingMapSequence reduce(_:_:)用法及代碼示例
- Swift AsyncThrowingPrefixWhileSequence drop(while:)用法及代碼示例
- Swift AsyncThrowingMapSequence contains(_:)用法及代碼示例
- Swift AsyncThrowingPrefixWhileSequence filter(_:)用法及代碼示例
- Swift AsyncThrowingCompactMapSequence drop(while:)用法及代碼示例
- Swift AsyncThrowingFilterSequence drop(while:)用法及代碼示例
- Swift AsyncThrowingCompactMapSequence prefix(while:)用法及代碼示例
- Swift AsyncThrowingStream filter(_:)用法及代碼示例
注:本文由純淨天空篩選整理自apple.com大神的英文原創作品 AsyncThrowingDropWhileSequence dropFirst(_:)。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
