<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/EmptyCollection/popLast()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:SKs11SubSequenceQzRszrlE7popLast7ElementQzSgyF::SYNTHESIZED::s:s15EmptyCollectionV"
  },
  "title" : "popLast()"
}
-->

# popLast()

Removes and returns the last element of the collection.

```
mutating func popLast() -> Self.Element?
```

## Return Value

The last element of the collection if the collection has one
or more elements; otherwise, `nil`.

## Discussion

You can use `popLast()` to remove the last element of a collection that
might be empty. The `removeLast()` method must be used only on a
nonempty collection.

> Complexity: O(1)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)