- For example, statements like
x = y + 1
are unintuitive because the right side of the equality is executed before the assignment.- Especially since many students are used to reading from right to left, the order of execution takes extra effort to internalize.
- Remind students that variables always resolve expressions to a value or an object since students may believe that variables can store unresolved mathematical expressions.
- When we have the assignment
var1 = var2 + var3
, they assume that a change tovar2
orvar3
after this assignment will changevar1
change without explicitly reassigningvar1
. - This is because they think
var1
holds the expressionvar2+var3
not the value of the result.
- When we have the assignment