Skip to content

Instantly share code, notes, and snippets.

@thibaultcha
Created November 30, 2015 19:54
Show Gist options
  • Save thibaultcha/b67f6aad6bfab4cbd3aa to your computer and use it in GitHub Desktop.
Save thibaultcha/b67f6aad6bfab4cbd3aa to your computer and use it in GitHub Desktop.
Lua metamethods table
Sean Conner
http://lua-users.org/lists/lua-l/2015-04/msg00033.html
5.1 5.2 5.3 function
__add * * * a + b
__sub * * * a - b
__mul * * * a * b
__div * * * a / b
__mod * * * a % b
__pow * * * a ^ b
__umn * * * -a
__idiv * a // b
__band * a & b
__bor * a | b
__bxor * a ~ b
__bnot * ~a
__shl * a << b
__shr * a >> b
__concat * * * a .. b
__len * * * #a
__eq * * * a == b
__lt * * * a < b
__le * * * a > b
__index * * * a = b[] can be table
__newindex * * * a[] = b can be table
__call * * * a()
__gc * * *
__mode * * * string
__metatable * * * table
__tostring * * *
__ipairs *
__pairs * *
__name * string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment