Returns a subsequence containing all but the specified number of final elements.
지정된 수의 최종 요소를 제외한 모든 요소를 포함하는 시퀀스를 반환합니다.
k
A subsequence that leaves off k elements from the end.
k개의 요소를 끝에서부터 분리하는 시퀀스입니다.
If the number of elements to drop exceeds the number of elements in the collection, the result is an empty subsequence.
삭제할 요소의 수가 컬렉션의 요소 수를 초과하면 결과는 비어 있는 시퀀스가 됩니다.
let numbers = [1, 2, 3, 4, 5]
print(numbers.dropLast(2))
// Prints "[1, 2, 3]"
print(numbers.dropLast(10))
// Prints "[]"
Complexity: O(1) if the collection conforms to RandomAccessCollection; otherwise, O(k), where k is the number of elements to drop.
복잡성: 수집이 랜덤 액세스 수집을 준수하는 경우 O(1)이고, 그렇지 않은 경우 O(k), 여기서 k는 삭제할 요소의 수입니다.