I've never seen getmetatable used anywhere. Is it useless? Can't you just return the setmetatable and cache it into a variable?
You could do something like this:
local tab = {}
function tab.new()
return setmetatable({}, tab)
end
local s = tab.new() -- here is your metatable

1 comment
getmetatable is not useless. The call
setmetatable(x, m)setsmto bex's metatable. You can **get**x's metatable by callinggetmetatable(x). getmetatable(x) will return nil ifx` has no metatable.