---
title: "drop(while:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/taskgroup/drop(while:)"
---

# drop(while:)

Omits elements from the base asynchronous sequence until a given closure returns false, after which it passes through all remaining elements.

## Declaration

```swift
@preconcurrency func drop(while predicate: @escaping @Sendable (Self.Element) async -> Bool) -> AsyncDropWhileSequence<Self>
```

## Parameters

- `predicate`: A closure that takes an element as a parameter and returns a Boolean value indicating whether to drop the element from the modified sequence.

## Return Value

Return Value An asynchronous sequence that skips over values from the base sequence until the provided closure returns false.

## Discussion

Discussion Use drop(while:) to omit elements from an asynchronous sequence until the element received meets a condition you specify. In this example, an asynchronous sequence called Counter produces Int values from 1 to 10. The drop(while:) method causes the modified sequence to ignore received values until it encounters one that is divisible by 3: let stream = Counter(howHigh: 10)     .drop { $0 % 3 != 0 } for await number in stream {     print(number, terminator: " ") } // Prints "3 4 5 6 7 8 9 10 " After the predicate returns false, the sequence never executes it again, and from then on the sequence passes through elements from its underlying sequence as-is.

## See Also

### Accessing an Asynchronous Sequence of Results

- [makeAsyncIterator()](swift/taskgroup/makeasynciterator().md)
- [allSatisfy(_:)](swift/taskgroup/allsatisfy(_:).md)
- [compactMap(_:)](swift/taskgroup/compactmap(_:)-944od.md)
- [compactMap(_:)](swift/taskgroup/compactmap(_:)-7mgj1.md)
- [contains(_:)](swift/taskgroup/contains(_:).md)
- [contains(where:)](swift/taskgroup/contains(where:).md)
- [dropFirst(_:)](swift/taskgroup/dropfirst(_:).md)
- [filter(_:)](swift/taskgroup/filter(_:).md)
- [first(where:)](swift/taskgroup/first(where:).md)
- [flatMap(_:)](swift/taskgroup/flatmap(_:)-vhi3.md)
- [map(_:)](swift/taskgroup/map(_:)-58nsr.md)
- [map(_:)](swift/taskgroup/map(_:)-4a4kq.md)
- [max()](swift/taskgroup/max().md)
- [max(by:)](swift/taskgroup/max(by:).md)
- [min()](swift/taskgroup/min().md)
