LuaMetatables


Syntax

  • [[local] mt = ]getmetatable(t) --> retrieve associated metatable for 't'
  • [[local] t = ]setmetatable(t, mt) --> set the metatable for 't' to 'mt' and returns 't'

Parameters

ParameterDetails
tVariable referring to a lua table; can also be a table literal.
mtTable to use as a metatable; can have zero or more metamethod fields set.

Remarks

There are some metamethods not mentioned here. For the full list and their usage, see the corresponding entry in the lua manual.