OxL Reference

method List.get

Element at i or none.

Example:

oxl✓ checked in CI
fn main() io {
  var xs = [1, 2, 3]
  xs.reverse()
  print("{xs}")
}
Output
[3, 2, 1]

Example:

oxl✓ checked in CI
fn main() io {
  let xs = [1, 2, 3]
  print("{xs.contains(2)} {xs.contains(9)}")
}
Output
true false

Example:

oxl✓ checked in CI
fn main() io {
  var xs = [1, 2, 3]
  xs.clear()
  print("{xs.len()}")
}
Output
0

Example:

oxl✓ checked in CI
fn main() io {
  var xs = ["a", "b", "c"]
  let b = xs.remove(1)
  print("{b} {xs}")
}
Output
b ["a", "c"]

Example:

oxl✓ checked in CI
fn main() io {
  var xs = [1, 3]
  xs.insert(1, 2)
  print("{xs}")
}
Output
[1, 2, 3]

Example:

oxl✓ checked in CI
fn main() io {
  let xs = ["a", "b"]
  print("{xs.get(1)} {xs.get(5)}")
}
Output
b none
pub(api) fn get(i: usize) -> T?

Since. 1.0.0-beta

Parameters

NameType
iusize

Returns

T?

Effects

none declared (pure unless the body says otherwise)

Defined in: std/core/collections.oxl:181

See also