firstRange(of:)
Finds and returns the range of the first occurrence of a given collection within this collection.
- iOS
- 16.0+
- macOS
- 13.0+
- tvOS
- 16.0+
- watchOS
- 9.0+
func firstRange<C>(of other: C) -> Range<Self.Index>? where C : Collection, Self.Element == C.Element
Parameters
- other
The collection to search for.
Returns
A range in the collection of the first occurrence of sequence
. Returns nil if sequence
is not found.