Instance Method

min()

Returns the minimum element in the sequence.

Declaration

@warn_unqualified_access func min() -> UInt8?

Return Value

The sequence’s minimum element. If the sequence has no elements, returns nil.

Discussion

This example finds the smallest value in an array of height measurements.

let heights = [67.5, 65.7, 64.3, 61.1, 58.5, 60.3, 64.9]
let lowestHeight = heights.min()
print(lowestHeight)
// Prints "Optional(58.5)"

Complexity: O(n), where n is the length of the sequence.

See Also

Finding Bytes

func first(where: (UInt8) -> Bool) -> UInt8?

Returns the first element of the sequence that satisfies the given predicate.

func max() -> UInt8?

Returns the maximum element in the sequence.

func max(by: (UInt8, UInt8) -> Bool) -> UInt8?

Returns the maximum element in the sequence, using the given predicate as the comparison between elements.

func min(by: (UInt8, UInt8) -> Bool) -> UInt8?

Returns the minimum element in the sequence, using the given predicate as the comparison between elements.

func range(of: Data, options: Data.SearchOptions, in: Range<Data.Index>?) -> Range<Data.Index>?

Finds the range of the specified data as a subsequence of this data, if it exists.

typealias Data.SearchOptions

Options that control a data search operation.