---
title: "remove(_:within:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/rangeset/remove(_:within:)"
---

# remove(_:within:)

Removes the range that contains only the specified index from the range set.

## Declaration

```swift
mutating func remove<C>(_ index: Bound, within collection: C) where Bound == C.Index, C : Collection
```

## Parameters

- `index`: The index to remove from the range set. index must be a valid index of collection that isn’t the collection’s endIndex.
- `collection`: The collection that contains index.

## Discussion

Discussion note: O(n), where n is the number of ranges in the range set.
