API Reference › List › List.push
method

List.push

List.push(s, v) -> void

Adds v to the end of s, growing the backing buffer if needed, so the slice's length increases by one. It is the same operation as the bare push(s, v). Because a slice is shared, the new element is visible to every holder. Use it to collect spawned entities, build a list of hits, or fill an inventory.

Parameters

sthe slice to append to
vthe element to add (matching the slice's element type)

Example

program Collect {
  var picked: []int = new []int

  handler Grab phase Update {
    List.push(picked, 7)
  }
}
← All symbols