---
title: "removeSubranges(_:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/arrayslice/removesubranges(_:)-k50b"
---

# removeSubranges(_:)

Removes the elements at the given indices.

## Declaration

```swift
mutating func removeSubranges(_ subranges: RangeSet<Self.Index>)
```

## Parameters

- `subranges`: The indices of the elements to remove.

## Discussion

Discussion For example, this code sample finds the indices of all the negative numbers in the array, and then removes those values. var numbers = [5, 7, -3, -8, 11, 2, -1, 6] let negativeIndices = numbers.indices(where: { $0 < 0 })

numbers.removeSubranges(negativeIndices) // numbers == [5, 7, 11, 2, 6] note: O(n), where n is the length of the collection.
