Mutation and assignment
Add mut when the binding itself must change. Assignment is a statement and produces no value. Compound forms such as +=, *=, and <<= read and write the target once.
moon does not convert the assigned value implicitly, so the right side must already have the target's type.
fn main() {
let mut score = 5
score += 1
score *= 4
println(score)
}
Examples use the moon toolchain version shown beside each result.
Output & diagnostics
Expected: 24
Ctrl/⌘+Enter runs the current lesson.