lua-users home
lua-l archive

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


I've seen some people have a _G.NULL = {} so it's only ever equal to itself.

On Mon, Jul 3, 2017, 14:04 J Doe <general@nativemethods.com> wrote:
Hi,

On Jul 3, 2017, at 2:49 PM, Charles Heywood <vandor2012@gmail.com> wrote:

A table can't have nil values. If you set a value to nil in a table, the key (k) will be removed.

Ah, I knew I was missing something obvious!  Thank you.

A question, though - I thought one of the reasons that the use of nil in determining the length (size) of a table was not done because a table could in fact have nil values and that the presence of one or more nil values in the table would invalidate determining the size if it just walked the table until it hit a nil value ?

As a side question of that - how do people model a table or array-type structure that has nils ?  Is a sentinel value like 0 used instead ?

Again, apologies if this is a really basic question - I'm still waiting for my Monday coffee to take effect!

Thanks,

- J
--
--
Ryan <vandor2012@gmail.com>
Software Developer / System Administrator
https://hashbang.sh