[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua-5.1-alpha: length operator on tables (arrays) and nil values
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Wed, 14 Sep 2005 08:25:42 -0300
> > If you need a table with all args, use {...}. No need for pack.
>
> Hmmm... but... as mentioned by Michael.. would that handle arguments
> with nil values as well?
Yes, except that nil values do not show up when traversing tables with pairs
or ipairs. So, build a table only if you need it. But perhaps you need
a = { n=select( "#", ... ), ...}
if your code uses a.n.
> What's the proper way to enumerate vararg then?
Your test2 and test3 are fine. They will even work for trailing nils.
The key is to get the number with select( "#", ... ).
--lhf