实例方法
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 AsyncPrefixWhileSequence drop(while:)用法及代码示例
- Swift AsyncPrefixWhileSequence reduce(_:_:)用法及代码示例
- Swift AsyncPrefixWhileSequence compactMap(_:)用法及代码示例
- Swift AsyncPrefixWhileSequence min()用法及代码示例
- Swift AsyncPrefixWhileSequence contains(where:)用法及代码示例
- Swift AsyncPrefixWhileSequence allSatisfy(_:)用法及代码示例
- Swift AsyncPrefixWhileSequence filter(_:)用法及代码示例
- Swift AsyncPrefixWhileSequence max()用法及代码示例
- Swift AsyncPrefixWhileSequence first(where:)用法及代码示例
- Swift AsyncPrefixWhileSequence min(by:)用法及代码示例
- Swift AsyncPrefixWhileSequence max(by:)用法及代码示例
- Swift AsyncPrefixWhileSequence contains(_:)用法及代码示例
- Swift AsyncPrefixWhileSequence prefix(_:)用法及代码示例
- Swift AsyncPrefixWhileSequence flatMap(_:)用法及代码示例
- Swift AsyncPrefixWhileSequence prefix(while:)用法及代码示例
- Swift AsyncPrefixWhileSequence map(_:)用法及代码示例
- Swift AsyncPrefixSequence dropFirst(_:)用法及代码示例
- Swift AsyncPrefixSequence contains(_:)用法及代码示例
- Swift AsyncPrefixSequence filter(_:)用法及代码示例
- Swift AsyncPrefixSequence max(by:)用法及代码示例
- Swift AsyncPrefixSequence contains(where:)用法及代码示例
- Swift AsyncPrefixSequence first(where:)用法及代码示例
- Swift AsyncPrefixSequence map(_:)用法及代码示例
- Swift AsyncPrefixSequence max()用法及代码示例
- Swift AsyncPrefixSequence min(by:)用法及代码示例
注:本文由纯净天空筛选整理自apple.com大神的英文原创作品 AsyncPrefixWhileSequence dropFirst(_:)。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
