According to this answer, to obtain the maximum of an array we can do:
let nums = [1, 6, 3, 9, 4, 6]; let numMax = nums.reduce(Int.min, { max($0, $1) })
Swift 4 has a .max() method for Array.
.max()
Array
Example:
let floats: Array = [2.45, 7.21, 1.35, 10.22, 2.45, 3] let max = floats.max()
Note: max() returns an optional so there's a chance it could come back nil.
max()