Back to Lo

It Lastindexof

docs/data/it-lastindexof.md

1.53.0464 B
Original Source

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:

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