Arrays

[T] is a dynamic array whose elements share one type. Indexing is bounds-checked. Methods cover mutation, safe selection, mapping, filtering, grouping, ordering, and aggregation.

Arrays are reference values, so another binding aliases the same collection. A structural change such as push is visible through both names. Non-mutating helpers return fresh arrays.

fn main() {
  let values = [1, 2, 3]
  let alias = values
  alias.push(4)
  println(values)
  println(values.map(|x| x * 2))
  println(values[3])
}
Output & diagnostics
Expected:
[1, 2, 3, 4]
[2, 4, 6, 8]
4
Ctrl/⌘+Enter runs the current lesson.