Skip to content

Instantly share code, notes, and snippets.

@zulonas
Forked from xytis/gist:5361405
Last active August 27, 2020 13:04
Show Gist options
  • Save zulonas/c4bc8e070b0204cc9632c58e814b58af to your computer and use it in GitHub Desktop.
Save zulonas/c4bc8e070b0204cc9632c58e814b58af to your computer and use it in GitHub Desktop.
Print Lua table recursively.
local function tprint(tbl, indent)
if not indent then indent = 0 end
for k, v in pairs(tbl) do
local formatting = string.rep(" ", indent) .. k .. ": "
if type(v) == "table" then
print(formatting)
tprint(v, indent+1)
else
print(formatting .. tostring(v))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment