Increment and Decrement
Jyro provides prefix and postfix increment/decrement operators for numeric values.
Postfix
Postfix operators return the original value, then modify the variable:
var x = 5
var y = x++ # y is 5, x is now 6
var z = x-- # z is 6, x is now 5
Prefix
Prefix operators modify the variable first, then return the new value:
var x = 5
var y = ++x # x is now 6, y is 6
var z = --x # x is now 5, z is 5
Summary
| Operator | Returns | Effect |
|---|---|---|
x++ | Old value of x | Increments x by 1 |
x-- | Old value of x | Decrements x by 1 |
++x | New value of x | Increments x by 1 |
--x | New value of x | Decrements x by 1 |