14 Replies
in Lua, which i used before, this would be done like this
so i dont get why it only outputs 3 numbers?
is 11 <= 10?
it prints 3 numbers because your i variable starts at 2, and your condition is i <= 10 or until it reaches 10, and each loop ur adding += 3 to ur i variable
first loop prints 2 since your starting from i=2
then ur adding += 3 to i, so it becomes 5
next again adding += 3, turns 5 into 8, and adding another 3 would break the loop since it has reached 10
this kinda omits the fact that the
i <= 10
check is done before entering the loop body, not after
which i assume is where they're confusedyea I was a little confused too at first until I did a little test
didn't know u could i+=3 instead of i++
you can have any expression there
I see
you can even do
for (; true; SomeMethod())
or for (;;)
testing in lua, only three numbers printed so i think they just make a mistake or forget what actually happen
if ur using lua, heres a doc explaining the for loop syntax

tysm guys, i understand it now.