lua loop through array code example
Example 1: lua for each in table
for k,v in pairs(table) do
-- k is key
-- v is value
end
Example 2: lua in pairs
--Table is the table to iterate through
--Index is the current index
--Value is the value at the current index
for index, value in pairs(table) do
end
Example 3: lua for loop
-- For K,V in table
for k,v in pairs(tbl) do
print(k)
print(v)
end
-- For i=0, num
for i=0, num do
print(i)
end