Skip to the content.

Control flow

Argon has the control flow constructs you’d expect from a scripting language:

A condition is always wrapped in parentheses, and the body is either a do block or a single statement:

let x = 5

if (x > 0) do
    term.log("positive")
    term.log("still positive")

if (x > 0) term.log("positive")

See Syntax basics for how do blocks and indentation work.

if, while, for and try are statements, not expressions: they can’t be used as a value (e.g. let y = if (x) 1 is a syntax error). Use the ternary operator or a do block for conditional values.

Next