lua-users home
lua-l archive

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




On 23/02/17 10:35 AM, Roberto Ierusalimschy wrote:
I want `a.b.c.d.e`. I'm going to test for nil, and I don't care
at what level the missing index is.

[...]
PiL 4 suggests the following method:

   E = {}      -- (somewhere in your code)

   ((((a or E).b or E).c or E).d or E).e

-- Roberto


This eats `false`, instead of choking on it.

--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.