For questions about single operators that assign a value based on both a previous value and an operand (e.g., the += operator in C or Python). Also referred to as "augmented assignment." Use this tag if your problem specifically involves or relates to a compound-assignment operator.
Compound assignment operators, such as +=
, combine aspects of assignment with aspects of regular binary operators. For example, i += 42
generally has the effect of i = i + 42
, but is more concise.
However, that is not always the case. For example, in a Python 3 class, a custom +
can be implemented using the __add__
method, and a custom +=
can be implemented using the __iadd__
method. Those two methods could behave very differently.