method
List.index_of
List.index_of(s, v) -> int
Scans s and returns the index of the first element equal to v, or -1 if none match. It uses the same value/identity comparison as List.contains, but tells you where the match is so you can act on it — swap it out, read a parallel slice at the same index, or guard with if idx >= 0. Only the first match is reported.
Parameters
sthe slice to searchvthe value to locateExample
program FindSlot {
var ids: []int = new []int
handler Locate phase Update {
let slot = List.index_of(ids, 99)
if slot >= 0 {
List.swap(ids, slot, List.len(ids) - 1)
}
}
}