Skip to main content

getmetatable

Function getmetatable 

Source
pub fn getmetatable(object: any) -> option<table>
Expand description

If object does not have a metatable, returns nil. Otherwise, if the metatable has a __metatable field, returns the associated value. Otherwise, returns the metatable of the given object.

§Examples

print(getmetatable({}))            --> nil
print(getmetatable(""))            --> table: 0x...  (the string metatable)
local t = setmetatable({}, { __metatable = "locked" })
print(getmetatable(t))             --> locked