- 1
What do statements like x-=y+=z mean?
There are 2 assignment operators used. So this is confusing for me. Please help.
2 odpowiedzi
+ 5
Are you sure its x-=y+=z or you ment
x-=y;
y+=z;
Because x -= y; simply means
x = x - y; but it's shortened way of syntax
y += z; means
y = y + z;
This can be also used with more operations.. a*=a;
0
If assignment operators follow the left-to-right operation precedence, then:
x -= y += z
would first subtract y from x:
x -= y
Then it would add z to y:
y += z
In end:
x = x - y
y = y + z
z = z