---
title: "removingSubranges(_:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/lazydropwhilesequence/removingsubranges(_:)"
---

# removingSubranges(_:)

Returns a collection of the elements in this collection that are not represented by the given range set.

## Declaration

```swift
func removingSubranges(_ subranges: RangeSet<Self.Index>) -> DiscontiguousSlice<Self>
```

## Parameters

- `subranges`: A range set representing the indices of the elements to remove.

## Return Value

Return Value A collection of the elements that are not in subranges.

## Discussion

Discussion For example, this code sample finds the indices of all the vowel characters in the string, and then retrieves a collection that omits those characters. let str = "The rain in Spain stays mainly in the plain." let vowels: Set<Character> = ["a", "e", "i", "o", "u"] let vowelIndices = str.indices(where: { vowels.contains($0) })

let disemvoweled = str.removingSubranges(vowelIndices) print(String(disemvoweled)) // Prints "Th rn n Spn stys mnly n th pln." note: O(n), where n is the length of the collection.
