Files
lo/docs/data/core-lastindexof.md
T
2025-10-06 17:15:49 +02:00

577 B

name, slug, sourceRef, category, subCategory, playUrl, variantHelpers, similarHelpers, position, signatures
name slug sourceRef category subCategory playUrl variantHelpers similarHelpers position signatures
LastIndexOf lastindexof find.go#L27 core find https://go.dev/play/p/Eo7W0lvKTky
core#find#lastindexof
core#find#indexof
core#find#findkey
core#find#findlastindexof
10
func LastIndexOf[T comparable](collection []T, element T) int

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

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

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