Skip to content

Commit cdbfc4f

Browse files
committed
Improved documentation for popLast() with note about performance versus removeLast()
1 parent 23c1514 commit cdbfc4f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

stdlib/public/core/BidirectionalCollection.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,12 @@ extension BidirectionalCollection where SubSequence == BidirectionalSlice<Self>
204204

205205
extension BidirectionalCollection where SubSequence == Self {
206206
/// Removes and returns the last element of the collection.
207+
///
208+
/// popLast() should generally be preferred over removeLast()
209+
/// since it is safer to use.
210+
///
211+
/// You should only opt for removeLast() if you are certain the collection
212+
/// is not empty and performance is an issue.
207213
///
208214
/// - Returns: The last element of the collection if the collection has one
209215
/// or more elements; otherwise, `nil`.

0 commit comments

Comments
 (0)