---
title: "relative(to:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/range/relative(to:)"
---

# relative(to:)

Returns the range of indices described by this range expression within the given collection.

## Declaration

```swift
func relative<C>(to collection: C) -> Range<Bound> where Bound == C.Index, C : Collection
```

## Parameters

- `collection`: The collection to evaluate this range expression in relation to.

## Return Value

Return Value A range suitable for slicing collection. The returned range is not guaranteed to be inside the bounds of collection. Callers should apply the same preconditions to the return value as they would to a range provided directly by the user.

## See Also

### Converting Ranges

- [init(_:in:)](swift/range/init(_:in:)-5cclx.md)
- [init(_:in:)](swift/range/init(_:in:)-5qfor.md)
