3 ms·
I think it goes well with the loop syntax. In contrast to C/C++ where you do for(i=0; i<n; i++) In Lua you do: for i=1..n On the Lua case, both the
by otikik 3y ago
I think it goes well with the loop syntax. In contrast to C/C++ where you do
for(i=0; i<n; i++)
In Lua you do:
for i=1..n
On the Lua case, both the beginning and end of the loop are inclusive.
If you have to iterate over n elements, the first syntax is optimized for 0 to n-1, while the second is optimized for the other case. See:
for(i=1; i<=n; i++) // <n becomes <=
for i=0..(n-1) -- ugh