What we take for granted in other languages and almost expect it to work in go, won\'t work - its almost so natural to do this, so why isn\'t the compiler happy? Just feeling li
Specifically, ++
and --
are statements because it can be very difficult to understand the order of evaluation when they're in an expression.
Consider the following:
// This is not valid Go!
x := 1
x = x++ + x
y := 1
y = ++y + y
What would you expect x
to be? What would you expect y
to be? By contrast, the order of evaluation is very clear when this is a statement.