---
title: removeFirst()
framework: swift
role: symbol
role_heading: Instance Method
path: swift/set/removefirst()
---

# removeFirst()

Removes the first element of the set.

## Declaration

```swift
@discardableResult mutating func removeFirst() -> Element
```

## Return Value

Return Value A member of the set.

## Discussion

Discussion Because a set is not an ordered collection, the “first” element may not be the first element that was added to the set. The set must not be empty. note: Amortized O(1) if the set does not wrap a bridged NSSet. If the set wraps a bridged NSSet, the performance is unspecified.

## See Also

### Removing Elements

- [filter(_:)](swift/set/filter(_:).md)
- [remove(_:)](swift/set/remove(_:)-8p2tv.md)
- [remove(_:)](swift/set/remove(_:)-4d3i1.md)
- [remove(at:)](swift/set/remove(at:).md)
- [removeAll(keepingCapacity:)](swift/set/removeall(keepingcapacity:).md)
