OxL Reference

method Iterable.iter

A lazy sequence of the elements, in the order for visits them. Implement it to make a type usable in for and in the queries of from ... in.

Example:

oxl✓ checked in CI
data Triple {
  base: i64
}

impl Triple {
  fn iter() -> iter<i64> => [base, base * 2, base * 3].iter()
}

fn total<I: Iterable<i64>>(xs: I) -> i64 {
  var s = 0
  for x in xs { s += x }
  s
}

fn main() io {
  print("{total(Triple(base: 5))}")
}
Output
30

A lazy sequence of the elements.

Example:

oxl✓ checked in CI
fn main() io {
  var total = 0
  for x in [1, 2, 3].iter() {
    total += x
  }
  print("{total}")
}
Output
6
fn iter() -> iter<T>

Complexity. O(1) to create.

Since. 1.0.0-beta

Returns

iter<T>

Effects

none declared (pure unless the body says otherwise)

Defined in: std/core/types.oxl:1123

See also