---
title: popFirst()
framework: swift
role: symbol
role_heading: Instance Method
path: swift/set/popfirst()
---

# popFirst()

Removes and returns the first element of the set.

## Declaration

```swift
mutating func popFirst() -> Element?
```

## Return Value

Return Value A member of the set. If the set is empty, returns nil.

## 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.

## See Also

### Excluding Elements

- [drop(while:)](swift/set/drop(while:).md)
- [dropFirst(_:)](swift/set/dropfirst(_:).md)
- [dropLast(_:)](swift/set/droplast(_:).md)
