Type Function Library (globals) Return value Table Revision Release 2025.3721 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.
getmetatable( object )
Table. A table for which to get the metatable.
local t = {}
t.name = "Joe"
local mt = {}
setmetatable( t, mt )
local another_t = {}
setmetatable( another_t, getmetatable(t) )