[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Any pitfalls to the nil index idiom?
- From: Javier Guerra Giraldez <javier@...>
- Date: Tue, 19 Jul 2016 13:28:56 +0100
On 19 July 2016 at 12:32, Oliver Kroth <oliver.kroth@nec-i.de> wrote:
> It returns a nil, but needs to return an empty table that can be indexed;
> nil can't be indexed.
it can after setting the metatable
> =a.b.c
stdin:1: attempt to index global 'a' (a nil value)
stack traceback:
stdin:1: in main chunk
[C]: at 0x00404750
> debug.setmetatable(nil,{__index={}})
> =a.b.c
nil
--
Javier