Metamethod
Metamethod is a term used in Lua to describe a special kind of function stored in a metatable that defines or overrides the behavior of operations and other language constructs on values that carry that metatable. Metamethods are not methods of the value itself; they are functions that the Lua runtime can invoke automatically to implement operator overloading and related behavior.
How metamethods work: When Lua evaluates an operation such as addition, indexing, or a function call, it
Common metamethods include add, sub, mul, div, mod, pow, and unm for arithmetic; eq, lt, and le
Implementation and usage: A metatable is a regular table attached to a value via setmetatable, and metamethod