lua-users home
lua-l archive

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


On Dec 6, 2011, at 8:17 PM, Ezequiel García wrote:

> What's the difference between
> require 'foo'.func() and require 'foo' 'bar' ?

If a function parameter is a table or a string, you do not need to wrap it within parenthesis.

So...

local function foo( ... )
end

foo 'bar'
foo {}
foo( 'bar' )
foo( {} )

... are all equivalent.

You can also make a table callable (see metamethod __call).

In that case, require returns a callable table, to which you can pass a parameter, which don't need to be parenthesis if it's a string or table.

Therefore:

local myFoo = require 'foo' 'bar'

Magic :)