Lua pour chacun dans le tableau
for k,v in pairs(table) do
-- k is key
-- v is value
end
Orion
for k,v in pairs(table) do
-- k is key
-- v is value
end
--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
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
-- // Tables
local t = {"foo", "bar"}
--[[
// Output:
1 foo
2 bar
--]]
for i,v in pairs(t) do
print(i,v)
end
-- // Dictionaries
local t = {
["A"] = "Me",
["B"] = "You"
}
--[[
// Output:
A Me
B You
--]]
for i,v in pairs(t) do
print(i, v)
end