lua-users home
lua-l archive

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


> > 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