---
title: "firstIndex(of:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/set/firstindex(of:)"
---

# firstIndex(of:)

Returns the index of the given element in the set, or nil if the element is not a member of the set.

## Declaration

```swift
func firstIndex(of member: Element) -> Set<Element>.Index?
```

## Parameters

- `member`: An element to search for in the set.

## Return Value

Return Value The index of member if it exists in the set; otherwise, nil.

## Discussion

Discussion note: O(1)

## See Also

### Finding Elements

- [subscript(_:)](swift/set/subscript(_:).md)
- [contains(where:)](swift/set/contains(where:).md)
- [allSatisfy(_:)](swift/set/allsatisfy(_:).md)
- [first(where:)](swift/set/first(where:).md)
- [firstIndex(where:)](swift/set/firstindex(where:).md)
- [index(of:)](swift/set/index(of:).md)
- [min()](swift/set/min().md)
- [min(by:)](swift/set/min(by:).md)
- [max()](swift/set/max().md)
- [max(by:)](swift/set/max(by:).md)
