API Reference › List › List.clear
method

List.clear

List.clear(s) -> void

Empties s by setting its length back to zero. The backing buffer is kept, so refilling the slice afterward reuses the same memory without reallocating. Use it to reset a per-frame list — collisions, visible tiles, particles to draw — at the start of each update instead of building a new slice every frame.

Parameters

sthe slice to empty

Example

program FrameHits {
  var hits: []int = new []int

  handler BeginFrame phase Update {
    List.clear(hits)   # start the frame with an empty list
  }
}
← All symbols