---
title: "indices(of:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/unicode/scalar/utf16view/indices(of:)"
---

# indices(of:)

Returns the indices of all the elements that are equal to the given element.

## Declaration

```swift
func indices(of element: Self.Element) -> RangeSet<Self.Index>
```

## Parameters

- `element`: An element to look for in the collection.

## Return Value

Return Value A set of the indices of the elements that are equal to element.

## Discussion

Discussion For example, you can use this method to find all the places that a particular letter occurs in a string. let str = "Fresh cheese in a breeze" let allTheEs = str.indices(of: "e") // str[allTheEs].count == 7 note: O(n), where n is the length of the collection.
