For loops index

Hi I have a question regarding the ‘i’ in for loops for Iterator statements;
for (int i = 0; i < listLength; i ++ )
{
Debug.Log( i )
}

When does the i first change value? Because wouldn’t it change from 0 to 1 before it runs the next line of code. (As in wouldn’t i be changed to 1 before the loop has even gone through once-because the i++ is right at the top)

Thanks

Hi,

i++ gets executed after the code-block was executed. See the figure on this website (“The below figure illustrates the execution steps of the for loop.”).

Is this what you wanted to know?


See also:

Yes that is exactly what I was referring too. I never realised this was the order. Doesn’t make linear sense but it explains why I couldn’t understand why it was written that way. Thank you :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms