Skip to Content
Lua Quick Start Guide
book

Lua Quick Start Guide

by Gabor Szauer
July 2018
Beginner
202 pages
5h 42m
English
Packt Publishing
Content preview from Lua Quick Start Guide

Math operators

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning Lua Programming

Beginning Lua Programming

Kurt Jung, Aaron Brown
Vim Masterclass

Vim Masterclass

Jason Cannon

Publisher Resources

ISBN: 9781789343229Supplemental Content