Increment and decrement operators — (++, --)
++symbol
symbol++
--symbol
symbol__
symbolA symbol whose value is a number.
The value of the symbol plus or minus one.
These operators perform auto-increments or decrements on numeric symbols.
When the ++ is placed before a symbol, it performs a
pre-increment, where the value is incremented and the result is the symbol's
value + 1. When ++ is placed after a symbol, it
performs a post-increment. Here the result of the operation is the value of
the symbol prior to being incremented. The -- operator
works in the same way. These operators only take symbols as arguments. It is
not possible to auto-increment or decrement an array element, list element,
or instance variable.
Gamma>a = 5;5Gamma>++ a;6Gamma>a;6Gamma>a ++;6Gamma>a;7Gamma>a = 5;5Gamma>-- a;4Gamma>a;4Gamma>a --;4Gamma>a;3Gamma>