Lua can handle for loops in two ways,
for i = 1,2,3,4 do
print(i)
end
and
for i=1,20 do
print(i)
end
What would happen if I was to use
for i=1,30,3 do
print(i)
end
Should it consider these are three values of 1, 30 and 3 or think of it as a loop from 1 to 30 with stepping of 3?
or should it be for i in 1,2,3,4,5 do
??
cheers,
?:)
LUA's numeric for loop construct is;
for = , , do
....
end
For example;
1. To loop from 1 to 100
1
2
3
| for i = 1, 100 do
print(i)
end |
Thanks Everyone,
I know about the for loops with the start, end, step and with the ipairs() and pairs()
I guess I had misread that it worked like the unix for loop where you can pass a series of values to the for loop. So I had this question, however I am unable to find the source where I got that confusion from, so I will take it that it is not possible with for in lua.
Thank you for trying to explain how for works, but that was not my question.
cheers,
?:)