by Entangled · 9y ago · 0 comments
// constructor
func init (a, b, c) {
if (!a) a = 0;
if (!b) b = 0;
if (!c) c = 0;
x = a; y = b; z = c;
}
Like func init (a=0, b=0, c=0) {
x = a; y = b; z = c;
}Nice touch to be able to do
func + (v) { ... } function init(a,b,c)
local x = a or 0
local y = b or 0
local z = c or 0
end
"and" and "or" short circuit evaluation in Lua; nil and false are false, everything else (including 0) is considered true.