Q:

table lua

    a = {}
    x = "y"
    a[x] = 10                 -- put 10 in field "y"
    print(a[x])   --> 10      -- value of field "y"
    print(a.x)    --> nil     -- value of field "x" (undefined)
    print(a.y)    --> 10      -- value of field "y"
1
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
0
local t = {
	"hello",
    "how",
    "are",
    "you"
}

for k,v in pairs(t) do
	print("Number: "..k.."Message: "..t)
end

output:
Number: 1 Message: hello
Number: 2 Message: how
Number: 3 Message: are
Number: 4 Message: you
2
for k,v in pairs(table) do 
 table.remove(table, k)
end
0

New to Communities?

Join the community