lua-users home
lua-l archive

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


On Sat, Nov 26, 2011 at 6:52 PM, Finn Wilcox <finnw@firecloudsw.co.uk> wrote:
> Peter Cawley wrote:
>>
>> Finally, it also looks acceptable as the table length:
>>
>> function print_funny(...)
>>  local args = table.pack(...)
>>  for i = 1, #args do print(">", args[i], "<") end
>> end
>>
> This is not consistent with the other methods if there are trailing nils,
> e.g. print_funny(1, nil, nil) gives n==3 but #args==1

The post was an exercise in examining different options. As __len
works for tables in 5.2, you can override what #args means, and
therefore make the example work.