【发布时间】:2018-10-25 07:22:06
【问题描述】:
我在其他代码中看到过这个东西,如果我理解正确的话应该这样使用:
t1 = {}
t1.__index = t2 --1
function t1:new()
local new = {}
setmetatable(new, {__index = t1}) --2
new.something = 0
return new
end
但他们真正做了什么,为什么有不同的写作方式?
【问题讨论】:
标签: oop lua lua-table metatable