Files
lo/docs/data/it-max.md
T
2025-10-08 19:35:53 +02:00

762 B

name, slug, sourceRef, category, subCategory, signatures, playUrl, variantHelpers, similarHelpers, position
name slug sourceRef category subCategory signatures playUrl variantHelpers similarHelpers position
Max max it/find.go#L295 it find
func Max[T constraints.Ordered](collection iter.Seq[T]) T
https://go.dev/play/p/9GaTX3-zf
it#find#max
core#slice#max
it#find#min
it#find#maxby
110

Searches the maximum value of a collection. Returns the largest element found.

Examples:

seq := func(yield func(int) bool) {
    _ = yield(5)
    _ = yield(2)
    _ = yield(8)
    _ = yield(1)
    _ = yield(9)
}
max := it.Max(seq)
// max == 9
seq := func(yield func(string) bool) {
    _ = yield("zebra")
    _ = yield("apple")
    _ = yield("banana")
}
max := it.Max(seq)
// max == "zebra" (lexicographically largest)