lua for loop through table code example
Example 1: lua loop through table
local Table = {'Cat', 'Dog', 'Bird'}
for i, v in pairs(Table) do
print(i .. ' ' .. v)
end
Example 2: for i in pairs lua
local table = {2,3,12, "Hello"} --a simple array
for i, item in pairs(table) do -- for i in pairs loop goes through all the items in an array/table
print(item)
end