API setmetatable

From Warcraft Wiki
Jump to navigation Jump to search

Sets the metatable for the given table.

table = setmetatable(table [, metatable])

Arguments

table
table - The table to assign or remove the metatable of.
metatable
table? - The metatable to be assigned, or nil to remove an existing metatable.

Returns

table
table - The table passed in as the first argument.

Details

  • The Lua 5.1 reference manual extensively documents the fields that can be set on a metatable.
  • As a non-standard extension, metatables can contain an __environment field which impacts the behavior of getfenv.

Patch changes

WoW Icon update.png Patch 1.1.0 (2004-11-07): Added.