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

# drop(while:)

Omits elements from the upstream publisher until a given closure returns false, before republishing all remaining elements.

## Declaration

```swift
func drop(while predicate: @escaping (Self.Output) -> Bool) -> Publishers.DropWhile<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 publisher’s output.

## Return Value

Return Value A publisher that skips over elements until the provided closure returns false.

## Discussion

Discussion Use drop(while:) to omit elements from an upstream publisher until the element received meets a condition you specify. In the example below, the operator omits all elements in the stream until the first element arrives that’s a positive integer, after which the operator publishes all remaining elements: let numbers = [-62, -1, 0, 10, 0, 22, 41, -1, 5] cancellable = numbers.publisher     .drop { $0 <= 0 }     .sink { print("\($0)") }

// Prints: "10 0, 22 41 -1 5"

## See Also

### Applying sequence operations to elements

- [drop(untilOutputFrom:)](combine/publisher/drop(untiloutputfrom:).md)
- [dropFirst(_:)](combine/publisher/dropfirst(_:).md)
- [tryDrop(while:)](combine/publisher/trydrop(while:).md)
- [append(_:)](combine/publisher/append(_:)-1qb8d.md)
- [append(_:)](combine/publisher/append(_:)-69sdn.md)
- [append(_:)](combine/publisher/append(_:)-5yh02.md)
- [prepend(_:)](combine/publisher/prepend(_:)-7wk5l.md)
- [prepend(_:)](combine/publisher/prepend(_:)-v9sb.md)
- [prepend(_:)](combine/publisher/prepend(_:)-5dj9c.md)
- [prefix(_:)](combine/publisher/prefix(_:).md)
- [prefix(while:)](combine/publisher/prefix(while:).md)
- [tryPrefix(while:)](combine/publisher/tryprefix(while:).md)
- [prefix(untilOutputFrom:)](combine/publisher/prefix(untiloutputfrom:).md)
