← Back to Week 1 Hub

Pre/Post Increment & Decrement

Workbook 1c, p.59 — Step-by-step debugger view

Increment Decrement

Scenario: x++ (Post-Increment)

Variable State

Ready
Click Next Step to begin execution.

Memory Tricks

x++ / x-- (Post)
"Use it, THEN change it"
The ++ / -- comes AFTER the variable,
so the change happens AFTER the value is used.
Think: "I'll deal with it later"
++x / --x (Pre)
"Change it, THEN use it"
The ++ / -- comes BEFORE the variable,
so the change happens BEFORE the value is used.
Think: "Change first, ask questions later"
Standalone? No Difference!
When used alone on its own line,
x++ and ++x do the exact same thing.
The difference only matters in expressions like y = x++
← Integer Division Widening vs Narrowing →