All of the following are binary mathematical operators. The meta method for each of these operators takes two arguments, the left- and the right-hand side of the equation. Each of the functions takes the following general form:
meta = {
__<method> = function(left, right)
-- Do stuff
end
}
Here are the names and a brief description of each binary mathematical meta method:
- __add: Addition, when writing "table + object" or "object + table"
- __sub: Subtraction, when writing "table - object" or "object - table"
- __mul: Multiplication, when writing "table * object" or "object * table"
- __div: Division, when writing "table / object" or "object / table"
- __mod: Modulo, when writing "table % object" or "object % table"
- __pow: Involution, when writing "table ^ object" or "object ^ table"