Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法在元表本身内部调用元表方法?例如
local t = {} local mt = { __index = { dog = function() print("bark") end, sound = function() t:dog() end } } setmetatable(t,mt) t:Sound()
引发此错误:
尝试调用方法“声音”(一个零值)
因为你没有Sound。只有sound.
Sound
sound