---
title: removeLast()
framework: swift
role: symbol
role_heading: Instance Method
path: swift/substring/utf16view/removelast()
---

# removeLast()

Removes and returns the last element of the collection.

## Declaration

```swift
@discardableResult mutating func removeLast() -> Self.Element
```

## Return Value

Return Value The last element of the collection.

## Discussion

Discussion The collection must not be empty. To remove the last element of a collection that might be empty, use the popLast() method instead. note: O(1)
