Skip to content

Instantly share code, notes, and snippets.

@hashmal
Created March 17, 2011 17:54
Show Gist options
  • Save hashmal/874792 to your computer and use it in GitHub Desktop.
Save hashmal/874792 to your computer and use it in GitHub Desktop.
[Lua] Print table contents recursively
-- Print contents of `tbl`, with indentation.
-- `indent` sets the initial level of indentation.
function tprint (tbl, indent)
if not indent then indent = 0 end
for k, v in pairs(tbl) do
formatting = string.rep(" ", indent) .. k .. ": "
if type(v) == "table" then
print(formatting)
tprint(v, indent+1)
else
print(formatting .. v)
end
end
end
@jfzlnyf
Copy link

jfzlnyf commented Apr 15, 2014

marked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment