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

# popFirst()

Removes and returns the first key-value pair of the dictionary if the dictionary isn’t empty.

## Declaration

```swift
mutating func popFirst() -> Dictionary<Key, Value>.Element?
```

## Return Value

Return Value The first key-value pair of the dictionary if the dictionary is not empty; otherwise, nil.

## Discussion

Discussion The first element of the dictionary is not necessarily the first element added. Don’t expect any particular ordering of key-value pairs. note: Averages to O(1) over many calls to popFirst().

## See Also

### Excluding Elements

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