“Como acessar um índice de uma tabela lua” Respostas de código

Tabelas Lua

local favoritefoods_table = {"hamburger", "spaghetti", "pizza", "potato chips"}
--the table--

for i, v in pairs(favoritefoods_table) do --loop through the table-- 
	print(i) --print the number--
  	print(v) --print the value--
end
Confused Cheetah

Como acessar um índice de uma tabela lua

--How to access something in a table by its index in lua:

local mytable = {"Hi", 6,"Bye"}

--To access it:

mytable[1]
--or
mytable[2]
--or
mytable[3]
Naughty Newt

Respostas semelhantes a “Como acessar um índice de uma tabela lua”

Perguntas semelhantes a “Como acessar um índice de uma tabela lua”

Procure respostas de código populares por idioma

Procurar outros idiomas de código