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

# index(of:)

Returns the first index where the specified value appears in the collection.

## Declaration

```swift
func index(of element: Self.Element) -> Self.Index?
```

## See Also

### Infrequently Used Functionality

- [init(_:)](swift/string/init(_:)-5a5lw.md)
- [init(stringInterpolation:)](swift/string/init(stringinterpolation:).md)
- [init(stringLiteral:)](swift/string/init(stringliteral:).md)
- [init(unicodeScalarLiteral:)](swift/string/init(unicodescalarliteral:).md)
- [init(extendedGraphemeClusterLiteral:)](swift/string/init(extendedgraphemeclusterliteral:).md)
- [customPlaygroundQuickLook](swift/string/customplaygroundquicklook.md)
- [withContiguousStorageIfAvailable(_:)](swift/string/withcontiguousstorageifavailable(_:).md)
