Liutauras Vilda wrote:
Roman Vilensky wrote:Right. I was mistaken about the order in which these happen. I thought it was assign old value, then increment, but it is the other way around.
Unclear whether you understood.
Not sure how that is exactly implemented, but I think always that way.
Campbell Ritchie wrote:Yes, i++ has two values, the value of i (increment) which you cannot see until later, and the old value (remember) which you see now as the value of the whole expression.Many people are surprised when it prints 123.
Jeanne Boyarsky wrote:The compiler things about it like this:
Ok. So first I execute i++. I'll remember that the original value is 0. Then I'll increment i to 1. Ah, I see you want the result of my statement set to i. No problem, that's the original value you told me to remember. (zero) Now i is set to 0