Skip to main content
3 of 3
edited title
Seggan
  • 3.1k
  • 10
  • 44

Why add an increment/decrement operator when compound assignments exist?

Many languages have compound assignment statements, for example +=. However, for the common task of adding or subtracting 1 from a variable some languages (mostly those close to C) have additional ++ and -- operators. For example, x += 1 can be written as x++ in these languages. Some languages decide not to have these operators. This can make some sense, as there is already a short way to increment something. Why would you add an increment/decrement operator when you have compound assignments? For completeness, I'll allow arguments for the other position as well.

Seggan
  • 3.1k
  • 10
  • 44