Revision: 12417
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 13, 2009 10:02 by ukpyr
Initial Code
--- Returns string representation of object obj
-- @return String representation of obj
function dir(obj,level)
local s,t = '', type(obj)
level = level or ' '
if (t=='nil') or (t=='boolean') or (t=='number') or (t=='string') then
s = tostring(obj)
if t=='string' then
s = '"' .. s .. '"'
end
elseif t=='function' then s='function'
elseif t=='userdata' then s='userdata'
elseif t=='thread' then s='thread'
elseif t=='table' then
s = '{'
for k,v in pairs(obj) do
local k_str = tostring(k)
if type(k)=='string' then
k_str = '["' .. k_str .. '"]'
end
s = s .. k_str .. ' = ' .. dir(v,level .. level) .. ', '
end
s = string.sub(s, 1, -3)
s = s .. '}'
end
return s
end
Initial URL
Initial Description
Initial Title
Dir (objects introspection like Python's dir)
Initial Tags
Initial Language
Lua