OxL Reference

method iter.take

The first n elements; the element after them is never pulled.

Example:

oxl✓ checked in CI
fn main() io {
  print("{[1, 2, 3, 4].iter().take(2).collect()}")
}
Output
[1, 2]
pub(api) move fn take<I>(n: I) -> iter<T>

Complexity. O(1) to build; pulls at most `n` elements of the source.

Since. 1.0.0-beta

Parameters

NameType
nI

Returns

iter<T>

Effects

none declared (pure unless the body says otherwise)

Defined in: std/core/iter.oxl:196

See also