API Reference › List › List.len
method

List.len

List.len(s) -> int

Returns how many elements s currently holds. It reads the slice's length, which changes as you List.push and List.pop, and is the same value as the bare len(s). Use it to bound a loop, test for emptiness, or find the last index with List.len(s) - 1.

Parameters

sthe slice to measure

Example

program CountEnemies {
  var enemies: []int = new []int

  handler Report phase Update {
    let n = List.len(enemies)
  }
}
← All symbols