lua __index的简写

标准写法是:
local b = {}
b.__index = {}

function b.__index:func1(name)
...
end
function b.__index:func2(name)
...
end

简写:
local b = {}
b.__index = b

function b:func1(name)
...
end
function b:func2(name)
...
end

posted @ 2021-06-25 15:58  HaHahahahaaaa  阅读(43)  评论(0编辑  收藏  举报