Back to Lo

Core Indexof

docs/data/core-indexof.md

1.53.0198 B
Original Source

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

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

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