Return Value 戻り値
A subsequence terminating at the end of the collection with at most max
elements.
コレクションの末端で終わる多くともmax
要素の下位シーケンス。
Availability 有効性
Technology
func suffix(_ maxLength: Int
) -> Self.SubSequence
A subsequence terminating at the end of the collection with at most max
elements.
コレクションの末端で終わる多くともmax
要素の下位シーケンス。
maxLength
The maximum number of elements to return.
返される要素の最大限の数。
The value of max
must be greater than or equal to zero.
If the maximum length exceeds the number of elements in the collection, the result contains all the elements in the collection. 最大長がコレクションの要素の数を超えるならば、結果はコレクションの要素すべてを含みます。
let numbers = [1, 2, 3, 4, 5]
print(numbers.suffix(2))
// Prints "[4, 5]"
print(numbers.suffix(10))
// Prints "[1, 2, 3, 4, 5]"
Complexity
O(1) if the collection conforms to Random
; otherwise, O(n), where n is the length of the collection.