Skip to main content

Better Method Creation

A series of methods was otherwise ugly to implement into a Lua table.

Old Code
local t = {}function t:f1(...) endfunction t:f2(...) endfunction t:f3(...) end

Now, you can inline these statements inside of your table.

New Code
local t = {    function f1() end,    function f2() end,    function f3() end}

This automatically marks the functions as methods.

caution

Keep in mind, this produces methods, meaning you'll need to use the colon invocation syntax to avoid positional ambiguities in your parameters.