lua-users home
lua-l archive

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

>2. The second argument to the next() function should be optional so that
>   next(foo, nil) is the same as next(foo).  I use next() regularly to test
>   if a table is empty (if next(tab) then print"not empty" end) and the 
>   additional nil is disturbing and inconsistent.

Surely it would be better to use a wrapper function:

  function isempty(t) 
    return not next(t, nil) 


Dr Alan Watson
Instituto de Astronomía UNAM