Back to Lo

Core Maxindex

docs/data/core-maxindex.md

1.53.0172 B
Original Source

Returns the maximum value and its index. Returns (zero value, -1) when the collection is empty.

go
value, idx := lo.MaxIndex([]int{2, 5, 3})
// value == 5, idx == 1