lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Nov 21, 2013, at 11:32 PM, Kevin Martin <> wrote:

> 2) I can guarantee that at some point in the future, that module which currently only has one function will need another, and the rewrite will be horrific if not returning a table.

Meh… behold the functable:

local aFunction = function() return 'Yeah!' end
debug.setmetatable( aFunction, { __index = function( self, aKey ) return aKey end } )

print( aFunction() )
print( )
print( )
print( aFunction.baz )