lua-users home
lua-l archive

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


Hi,

Kristofer Karlsson wrote:
> >The simplest way to check if a table is empty is probably this:
> function IsTableEmpty(t) return not next(t) end
> Of course, the negated function is much easier to define:
> function IsTableNotEmpty = next

Recurring discussion #42. That's wrong: false is a valid key.
You have to use next(t) == nil.

Recurring followup discussion #43 and #44: why both false and nil
are logically "false" and why nil is special. Please have a look
at the list archives and save us some bandwidth. Thank you. :-)

Bye,
     Mike