lua-users home
lua-l archive

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


On 5 April 2012 15:59, Enrico Colombini <erix@erix.it> wrote:
> On 05/04/2012 16.31, Dimitris Papavasiliou wrote:
>>
>> It doesn't bother me really and I imagine
>> it can be useful at times, [...]
>
>
> It can be useful, for example, to have 'nil propagation' in a chain of table
> accesses without having to check for key validity at each step.

In a "nested" chain like foo[bar[5]], yes. In an actual chain like
foo["bar"][5], no. Unless...

    $ lua
    Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
    > debug.setmetatable(nil, { __index = {} })
    > a = {}
    > =a.b.c.d
    nil

Regards,
Matthew (diving for cover)