9.6.4.4 Assignment ( << >> )
Assignment is performed using the assignment operators. Left assignment
x << 5 and right assignment 5 >> x. These operators are equivalent.
Assignment of a value to a variable defines the variable type. Once a
variable is 'typed' it cannot be assigned another type. Note there is no
scope, all variables are at the 'top level.'
Assignment Sugar ( <<+ +>> etc... )
Note: left and right assignment do not necessarily yield the same
results.
- Add Assign ( <<+, +>> ) - left assignment is x <<+ 5 is x << x + 5 whereas right assignment is 5 +>> x is 5 + x >> x.
- Subtract Assign ( <<-, ->> ) - left assignment is x <<- 5 is x << x - 5 whereas right assignment is 5 ->> x is 5 - x >> x. Left and right assignment are not the same here.
- Multiply Assign ( <<*, *>> ) - left assignment is x <<* 5 is x << x * 5 whereas right assignment is 5 *>> x is 5 * x >> x.
- Divide Assign ( <</, />> ) - left assignment is x <</ 5 is x << x / 5 whereas right assignment is 5 />> x is 5 / x >> x. Left and right assignment are not the same here.
- Remainder Assign ( <<%, %>> ) - left assignment is x <<% 5 is x << x % 5 whereas right assignment is 5 %>> x is 5 % x >> x. Left and right assignment are not the same here.