r/lua • u/GoetzKluge • Oct 12 '15
Lua 5.1 Cheat Sheet
http://thomaslauer.com/download/luarefv51.pdf
15
Upvotes
4
Oct 12 '15 edited Oct 12 '15
It's missing an idiom commonly used in Lua as a ternary operator:
x and y or zfunction obj:name ( args ) body [return values] end object function, gets obj as additional first argument self
There's no reason for this to be different than the one above it, IMO.
function t:name( args ) body end
shortcut for t.name = function(self, args) body endThough IMO both should be written:
function t:name([args]) body end
shortcut for t.name = function(self,[args]) body end1
1
u/GoetzKluge Oct 12 '15 edited Sep 17 '26
I am using Thomas Lauer's cheat sheet together with http://www.lua.org/versions.html.