Back to Lo

Core Lastindexof

docs/data/core-lastindexof.md

1.53.0205 B
Original Source

Returns the index of the last occurrence of a value in a slice, or -1 if not found.

go
idx := lo.LastIndexOf([]int{0, 1, 2, 1, 2, 3}, 2)
// 4

idx = lo.LastIndexOf([]int{0, 1, 2, 1, 2, 3}, 6)
// -1