Returns the maximum element in the sequence.
SDK
- Xcode 9.0+
Framework
- Swift Standard Library
Declaration
Return Value
The sequence’s maximum element. If the sequence has no elements, returns nil
.
Discussion
This example finds the largest value in an array of height measurements.
Complexity: O(n), where n is the length of the sequence.