i can't remember ever seeing select in all the codes I have studied so far. Looks cool. I won't mind more information on this beast.
On Wed, May 9, 2012 at 6:56 PM, Petite Abeille
<petite.abeille@gmail.com> wrote:
On May 9, 2012, at 7:18 PM, Emeka wrote:
> local t=table.pack(...)
> local n=t.n
> t.n=nil
Luiz uses table.pack, which adds a 'n' key to hold the overall length of the arguments. This is necessary to account for nil values.
That said, using table.pack seems to be more trouble than anything in that case. Using select directly seems to be more straightforward.
For example:
function NamedTable( someNames, ... )
local aMap = {}
for anIndex = 1, select( '#', ... ) do
aMap[ assert( someNames[ anIndex ] ) ] = select( anIndex, ... )
end
return aMap
end