Operators and precedence
Arithmetic binds more tightly than comparison, comparison more tightly than &&, and && more tightly than ||. Parentheses make a different grouping explicit. Logical operators short-circuit.
Integer values also support &, |, ^, and three shifts. >> preserves a sign bit; >>> shifts in zeros. A negative or oversized shift yields zero.
fn main() {
println(2 + 3 * 4)
println(10 > 3 && !false)
println((1 | 2) << 2)
}
Examples use the moon toolchain version shown beside each result.
Output & diagnostics
Expected: 14 true 12
Ctrl/⌘+Enter runs the current lesson.