---
title: "ranges(of:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/collection/ranges(of:)"
---

# ranges(of:)

Finds and returns the ranges of the all occurrences of a given sequence within the collection.

## Declaration

```swift
func ranges<C>(of other: C) -> [Range<Self.Index>] where C : Collection, Self.Element == C.Element
```

## Parameters

- `other`: The sequence to search for.

## Return Value

Return Value A collection of ranges of all occurrences of other. Returns an empty collection if other is not found.
