lua-users home
lua-l archive

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


Alan Watson wrote:
> Edgar Toernig wrote:
> >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)
>   end

What I wanted was a next function that is compatible to the standard lua
calling conventions.  In code:

    function next(a,b) return %next(a,b) end

Ciao, ET.