<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/Sequence/drop(while:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:STsE4drop5whiles17DropWhileSequenceVyxGSb7ElementQzKXE_tKF"
  },
  "title" : "drop(while:)"
}
-->

# drop(while:)

Returns a sequence by skipping the initial, consecutive elements that
satisfy the given predicate.

```
func drop(while predicate: (Self.Element) throws -> Bool) rethrows -> DropWhileSequence<Self>
```

## Parameters

`predicate`

A closure that takes an element of the sequence as
its argument and returns a Boolean value indicating whether the
element should be included in the result.

## Return Value

A sequence starting after the initial, consecutive elements
that satisfy `predicate`.

## Discussion

The following example uses the `drop(while:)` method to skip over the
positive numbers at the beginning of the `numbers` array. The result
begins with the first element of `numbers` that does not satisfy
`predicate`.

```
let numbers = [3, 7, 4, -2, 9, -6, 10, 1]
let startingWithNegative = numbers.drop(while: { $0 > 0 })
// startingWithNegative == [-2, 9, -6, 10, 1]
```

If `predicate` matches every element in the sequence, the result is an
empty sequence.

> Complexity: O(*k*), where *k* is the number of elements to drop from
> the beginning of the sequence.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)