method
List.first
List.first(s) -> T
Returns element 0 of s — the same as s[0], named for readability. The slice must hold at least one element; calling it on an empty slice reads out of bounds, so guard with List.len(s) > 0 when that is possible. Use it to peek at the head of a queue or the front of an ordered list.
Parameters
sa non-empty sliceExample
program Queue {
var waiting: []int = new []int
handler Serve phase Update {
if List.len(waiting) > 0 {
let next = List.first(waiting)
}
}
}