Assignment operators are shortcuts for performing mathematical operations and storing the results back into the same variable.
Key Concepts
The basic operator is =. Other operators are shortcuts:
Shortcut | Equivalent to… |
---|---|
x += 5 | x = x + 5 |
x -= 5 | x = x - 5 |
x *= 5 | x = x * 5 |
x /= 5 | x = x / 5 |