Type Function Library (globals) Return value Table Revision 2017.3060 Keywords getmetatable, setmetatable, metatables, tables See also setmetatable()
Gets the metatable of a specified Table. If the table does not have a metatable, it returns nil. Otherwise, if the object's metatable has a __metatable field, it returns the associated value. Otherwise, it returns the metatable of the given table.
local t = {}
t.name = "Joe"
local mt = {}
setmetatable( t, mt )
local another_t = {}
setmetatable( another_t, getmetatable(t) )