lua-users home
lua-l archive

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


> > The problem happens (for example) when you use multiple level tables
> > to store configurations. For example, you store something like:
> > 	config.network.server.url = "xxx"
> > If the parameter is optional, or if you do not want bad surprise, when
> > you want to use it you need to write:
> > 	if confg.network and config.network.server and config.network.server.url then
> > 		dosomething(config.network.server.url)
> > 	End
> 
> What about this?  (untested code...)
> 
> local emptytable = {}
> local function Opt (t) return t or emptytable end
> 
>   if config.Opt(network).Opt(server).url then
>     dosomething(config.network.server.url)
>   End

That does not make any sense. I do not know what I was thinking. Sorry
for the noise...

-- Roberto