Returns a sequence, up to the specified maximum length, containing the initial elements of the sequence.
SDK
- Xcode 10.2+
Framework
- Swift Standard Library
Declaration
Parameters
maxLength
The maximum number of elements to return. The value of
max
must be greater than or equal to zero.Length
Return Value
A sequence starting at the beginning of this sequence with at most max
elements.
Discussion
If the maximum length exceeds the number of elements in the sequence, the result contains all the elements in the sequence.
Complexity: O(1)