[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.2.0 (rc2) now available
- From: Peter Cawley <lua@...>
- Date: Sat, 26 Nov 2011 18:55:47 +0000
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.