Language / Flow control overview

Flow control overview

Silk has familiar structured control flow:

  • branching: if / else
  • loops: while, for, loop
  • structured matching: match
  • early exit: break, continue, return

Full reference: flow overview.

Notes#

  • Reference details: docs/language/flow-*.md

Example#

fn main () -> int {
  let mut sum: int = 0;

  for i in 0..5 {
    if i == 3 {
      continue;
    }
    sum += i;
  }

  if sum > 0 {
    return sum;
  }
  return 0;
}

See also#

Source repository · Edit this page · View Markdown