“Pares Lua” Respostas de código

lua para cada uma na mesa

for k,v in pairs(table) do
 -- k is key
 -- v is value
end
Orion

Lua em pares

--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
Dangerous Dog

para eu em pares 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
Drab Dingo

Pares Lua

-- // 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
Breakable Buzzard

Respostas semelhantes a “Pares Lua”

Perguntas semelhantes a “Pares Lua”

Procure respostas de código populares por idioma

Procurar outros idiomas de código