OxL Reference

method List.first

The first element, or none for an empty list.

Example:

oxl✓ checked in CI
fn main() io {
  let xs: List<i32> = []
  print("{[7, 8].first()} {xs.first()}")
}
Output
7 none

The first element or none.

Example:

oxl✓ checked in CI
fn main() io {
  print("{[7, 8].first()} {List<i32>.new().first()}")
}
Output
7 none
pub(api) fn first() -> T?

Complexity. O(1).

Since. 1.0.0-beta

Returns

T?

Effects

none declared (pure unless the body says otherwise)

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

See also