October 2015
Beginner to intermediate
400 pages
14h 44m
English
The value held by a variable is updated by an assignment statement,
which in its simplest form has a variable on the left of the =
sign and an expression on the right.
x = 1 // named variable *p = true // indirect variable person.name = "bob" // struct field count[x] = count[x] * scale // array or slice or map element
Each of the arithmetic and bitwise binary operators has a corresponding assignment operator allowing, for example, the last statement to be rewritten as
count[x] *= scale
which saves us from having to repeat (and re-evaluate) the expression for the variable.
Numeric variables can also be incremented and
decremented by ++ and -- statements:
Read now
Unlock full access