Removes and returns the last element of the collection.
SDK
- Xcode 8.0+
Framework
- Swift Standard Library
Declaration
mutating func popLast() -> Self.Element?
Available when Self is Sub Sequence.
Return Value
The last element of the collection if the collection has one or more elements; otherwise, nil.
Discussion
You can use pop to remove the last element of a collection that might be empty. The remove method must be used only on a nonempty collection.
Complexity: O(1)