Only a variable, a field or an index can be assigned (x = 1, p.x = 1, xs[i].y = 1), or with
a plain = a tuple of them ((a, b) = (b, a)). The left side here is some other expression,
like a call or an arithmetic result.
Wrong#
fn main() {
var a = 1
a + 1 = 3
print(a)
}Fixed#
fn main() {
var a = 1
a = 3 - 1
print(a)
}Common causes#
=used as a comparison in an expression: use==.- Assigning to a call result:
get(m) = v; usem[k] = vor a setter function. - An equation solved the wrong way round.
- A compound assignment to a tuple (
(a, b) += (1, 1)): assign each one.