--
| Syntax |
--identifier identifier--
|
| Action |
The decrement operator subtracts the numeric value 1 from the value of identifier. In the first case, where the decrement operator appears before identifier, the value of the decrement expression is the value of identifier after it is decremented. That is, the decrement operation takes place first, and the result is used as the value of the expression. In the second case, where the decrement operator appears after identifier, the value of the decrement expression is the value of identifier before it is decremented; the decrement operation takes place after the expression's value has been determined.
|
| Examples |
x = 3; --x » 2
Since x is "pre-decremented," its final value of 2 is the result of the expression.
In this case, x is "post-decremented," and the result of the expression is its value before 1 is subtracted from it. Its value after the statement is executed is still 2. |
| Notes |
Any type that supports subtraction can be used with the decrement operator.
|
| See Also |
-
|