#Diffrence between for loops
1 messages · Page 1 of 1 (latest)
here it is:
the first iteration (ipairs) assumes the indices to be numbers, guarantees that you iterate in order. does not work on dictionaries.
the second iteration does not make assumptions and just iterates. the order in which iteration occurs is NOT guaranteed.
the third iteration is a consolidation of the previous two.
if the table is an array [ordered number indices] then it acts like ipairs.
else, it acts like pairs.
** You are now Level 2! **
realistically, you don't need to use those anymore, no.
by default you can just do the:
for i, v in array do
end
And it will by default select the best option, if the array has numerical key it will use ipairs else pairs