OxL Reference

fn first

The first element, or none for an empty stream. Cancels the producer; an error of the stream is returned.

Example:

oxl✓ checked in CI
use std.stream { first }

fn nums() -> stream<i32> {
  for i in 5..8 { yield i }
}

fn main() io {
  print("{nums() |> first()}")
}
Output
5
pub(api) fn first<T, E>(s: stream<T, E>) -> T? | E

Since. 1.0.0-beta

Parameters

NameType
sstream<T, E>

Returns

T?

Errors

  • E

Effects

none declared (pure unless the body says otherwise)

Defined in: std/stream/stream.oxl:221

See also