---
title: "firstRange(of:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/bidirectionalcollection/firstrange(of:)-5sum7"
---

# firstRange(of:)

Finds and returns the range of the first occurrence of a given collection within this collection.

## Declaration

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

## Parameters

- `other`: The collection to search for.

## Return Value

Return Value A range in the collection of the first occurrence of sequence. Returns nil if sequence is not found.
