API Reference › List › List.contains
method

List.contains

List.contains(s, v) -> bool

Scans s and returns true if any element equals v. Comparison is by value for scalar elements (ints, entities, booleans) and by identity for reference elements. Use it for membership tests — has this tile been visited, is this entity already in the target list, is the achievement unlocked. It is a linear scan, so for very large or hot-path sets a dedicated structure will be faster.

Parameters

sthe slice to search
vthe value to look for

Example

program Visited {
  var seen: []int = new []int

  handler Step phase Update {
    let tile = 42
    if not List.contains(seen, tile) {
      List.push(seen, tile)
    }
  }
}
← All symbols