0
点赞
收藏
分享

微信扫一扫

打印lua内部结构的函数调用

勇敢的趙迦禾 2022-08-02 阅读 48

function printTableInner(t,depth)

for k,v in pairs(t) do

if type(v) == "table" then

print(string.rep(" ", depth)..'table,',k)

printTableInner(v,depth+1)

else

print(string.rep(" ", depth)..k..","..v )

end



end

end



function printTable(t)
for k,v in pairs(t) do
if type(v) == "table" then
print('table,',k)
printTableInner(v,1)
elseif type(v) == "function" then
print('function,',k)
else
print(k..",",v )
end
end
end

举报

相关推荐

0 条评论