In C-like languages,"x = x + y" can be coded as "x += y". This is a compound operator. There is such an operator for every arithmetic, logical and bit-wise operator.
x = x + y
can be abbreviated to x += y
.
These are similar in effect, but not identical for all languages.
For example, in Java, x += y
is equivalent to x = (type-of-x)(x + y)
, for example:
char x = 'a';
x += 1; // 'b'
compare with:
char x = 'a';
x = x + 1; // compile error: "incompatible types: possible lossy conversion from int to char"