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

814 B

name, slug, sourceRef, category, subCategory, signatures, playUrl, variantHelpers, similarHelpers, position
name slug sourceRef category subCategory signatures playUrl variantHelpers similarHelpers position
LastIndexOf lastindexof it/find.go#L34 it find
func LastIndexOf[T comparable](collection iter.Seq[T], element T) int
https://go.dev/play/p/2PaIZ3gc-n
it#find#lastindexof
core#slice#lastindexof
it#find#indexof
10

Returns the index at which the last occurrence of a value is found in the sequence, or -1 if the value is not found.

Examples:

seq := func(yield func(int) bool) {
    _ = yield(10)
    _ = yield(20)
    _ = yield(30)
    _ = yield(20)
}
idx := it.LastIndexOf(seq, 20)
// idx == 3
seq := func(yield func(string) bool) {
    _ = yield("apple")
    _ = yield("banana")
    _ = yield("cherry")
}
idx := it.LastIndexOf(seq, "orange")
// idx == -1