why do you use the pairs () function if you do not want the key / value pairs to be listed?
for example, this is even shorter:
local t = {"asdf", "sdfg", "dfgh"} for i=1,
otherwise, I always did this:
local t = {"asdf", "sdfg", "dfgh"} for _,v in pairs(t) do print(v) end
edit: for your scenario, where you want to list only the values ββin a table with non-numeric keys, perhaps the brightest thing you could do is write your own table iterator function as follows:
local t = {["asdf"] = 1, ["sdfg"] = 2, ["dfgh"] = 3} function values(tbl) local key = nil return function() key = next(tbl, key) return tbl[key] end end for value in values(t) do print(value) end
itβs very clear that you are only passing the values ββof table t. Like pairs (), this is not guaranteed to go in order, since it uses next ().
source share