I don’t have a use case for this yet, but I want to know whether there’s a way to traverse all elements in a nested table, without using two functions in this way:
local nested = {key = {
"str";
value = {
value2 = {"val";
value3 = {"value"}
}
}
}
}
local function iter(tab)
for k, v in pairs(tab) do
if typeof(v) ~= "table" then print(v)
else
loop(v)
end
end
end
function loop(t)
for _, v in pairs(t) do
if typeof(v) ~= "table" then print(v)
else
iter(v)
end
end
end
loop(nested)