Control Flow
Nubo includes straightforward control flow for branching and looping.
If Statements
Section titled “If Statements”Use if to run code conditionally:
if x > 1 { println("x is greater than 1")}Conditions usually use comparison operators such as ==.
For Loops
Section titled “For Loops”Use for to repeat code.
When looping over an integer, Nubo iterates from 0 up to that number:
for i in 15 { println(i)}This prints numbers starting from 0.
Loop Variables
Section titled “Loop Variables”The loop variable is available inside the loop body:
let sum = 0
for i in 10_000 { sum = sum + i}
println("Sum:", sum)Use break to exit a loop early:
fn x() void { for i in 10 { if i == 5 { break } }}
x()Nil Checks
Section titled “Nil Checks”Use nil to represent a missing value:
let value: string|nil = "Hello"
if isNil(value) { println("No value")}