---
title: "init(_:within:)"
framework: swift
role: symbol
role_heading: Initializer
path: "swift/rangeset/init(_:within:)"
---

# init(_:within:)

Creates a new range set containing ranges that contain only the specified indices in the given collection.

## Declaration

```swift
init<S, C>(_ indices: S, within collection: C) where Bound == S.Element, S : Sequence, C : Collection, S.Element == C.Index
```

## Parameters

- `collection`: The collection that contains index.
