--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
Code Example |
---|
Lua :: how do you close the lua program |
Lua :: roblox pairs |
Lua :: roblox rotate model |
Lua :: remove from table lua |
Lua :: lua sort |
Lua :: prompt developer product purchase roblox |
Lua :: roblox luau random number |
Lua :: lua object |
Lua :: lua how to add something to a table |
Lua :: datastore roblox |
Lua :: roblox studio rain |
Lua :: Roblox Luau Wait Alternative |
Lua :: Set core GUI Roblox |
Lua :: attempt to call a string value lua |
Lua :: fivem get closest player |
Lua :: swap number in lua |
Lua :: enable http service roblox |
Matlab :: matlab symbolic derivative |
Matlab :: matlab preallocate array size |
Matlab :: two return variables in matlab |
Basic :: git access token |
Basic :: robocopy sync one way |
Elixir :: elixir ecto query to sql |
Elixir :: elixir anonymous function |
Scala :: scala function |
Scala :: get last index of list scala |
Excel :: google sheets select item from split |
Perl :: perl loops |
Perl :: how to initialize an array |
Powershell :: Take ownership of a folder |