API Reference › Operators & tokens › Assignment
operator

Assignment

name = value

Assignment stores a value into a target — a var binding, a property field, or a buffer/slice element — with target = value. The compound forms +=, -=, *=, and /= update in place, so score += 1 means score = score + 1. Assignment is a statement, not an expression: it produces no value, so you cannot write if x = 0 (use == for the test). Only a mutable target accepts it — assigning to a let or const binding is a compile error — though you may still mutate through an immutable binding that holds a record or slice.

Example

var score: int = 0
score = 10
score += 5
let current_position = new_position()
current_position.column = current_position.column + 1
← All symbols