Understande the difference between prefix and postfix operators in Solidity
Postfix operators
uint8 i; // 0
emit log_uint(i++); // 0
emit log_uint(i); // 1
int8 i; // 0
emit log_int(i--); // 0
emit log_int(i); // -1
When the value is modified by the postfix operator the value of the expression is equal to the unmodified/old value.
Prefix operators
uint8 i; // 0
emit log_uint(++i); // 1
emit log_uint(i); // 1
int8 i; // 0
emit log_int(--i); // -1
emit log_int(i); // -1
When the value is modified by the prefix operator the value of this expression is equal to the modified/new value.
Reference
Join the garden
Finally
enjoy quality-first content.
'cause low-quality sucks