---
title: popLast()
framework: swift
role: symbol
role_heading: Instance Method
path: swift/substring/utf8view/poplast()
---

# popLast()

Removes and returns the last element of the collection.

## Declaration

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

## Return Value

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

## Discussion

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. note: O(1)
