ranges(of:)
Finds and returns the ranges of the all occurrences of a given sequence within the collection.
- iOS
- 16.0+
- macOS
- 13.0+
- tvOS
- 16.0+
- watchOS
- 9.0+
func ranges<C>(of other: C) -> [Range<Self.Index>] where C : Collection, Self.Element == C.Element
Parameters
- other
The sequence to search for.
Returns
A collection of ranges of all occurrences of other
. Returns an empty collection if other
is not found.