Skip to content

Commit f9cd8b1

Browse files
committed
Updated popLast() and removeLast() documentation.
1 parent 520d0d2 commit f9cd8b1

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

stdlib/public/core/BidirectionalCollection.swift

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,9 @@ extension BidirectionalCollection where SubSequence == BidirectionalSlice<Self>
205205
extension BidirectionalCollection where SubSequence == Self {
206206
/// Removes and returns the last element of the collection.
207207
///
208-
/// `popLast()` should generally be preferred over `removeLast()`.
209-
///
210-
/// You should only opt for `removeLast()` if you are certain the collection
211-
/// is not empty and performance is an issue.
208+
/// Use `popLast()` to remove the last element of a collection that might be empty.
209+
///
210+
/// The `removeLast()` method must be used only on a nonempty collection.
212211
///
213212
/// - Returns: The last element of the collection if the collection has one
214213
/// or more elements; otherwise, `nil`.
@@ -224,10 +223,10 @@ extension BidirectionalCollection where SubSequence == Self {
224223

225224
/// Removes and returns the last element of the collection.
226225
///
227-
/// You should only use this if you are certain the collection
228-
/// is not empty and performance is an issue.
229-
///
230-
/// Otherwise opt for `popLast()`.
226+
/// The collection must not be empty.
227+
///
228+
/// To remove the last element of a collection that might be empty,
229+
/// use the `popLast()` method instead.
231230
///
232231
/// - Returns: The last element of the collection.
233232
///

0 commit comments

Comments
 (0)