lua-users home
lua-l archive

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



On Jun 21, 2008, at 10:53 AM, Duck wrote:

will I get identical results from "require(fruit)" as I used to get
from "require('banana'); require('mango')"?

Yes, you can have multiple modules in one file.

For example, a DB module [1] could contain a DBCursor module [2].

Requiring the main module ('DB'), will load both 'DB' and 'DBCursor'.

You can further require any sub modules -once you have loaded the main one- to get a direct handle on each one of them, e.g.:

local DB = require( 'DB' )
local DBCursor = require( 'DBCursor' )

Cheers,

--
PA.
http://alt.textdrive.com/nanoki/

[1] http://dev.alt.textdrive.com/browser/HTTP/DB.lua#L24
[2] http://dev.alt.textdrive.com/browser/HTTP/DB.lua#L106