lua-users home
lua-l archive

Re: [manual] ipairs vs. #

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


2016年01月27日 19:11 GMT+02:00 Stephan Hennig <sh-list@posteo.net>:
> The fact that iterating over table elements via ipairs and iterating over
> table indices 1 to #t are not equal operations has been discussed on
> this list before. But it is neither mentioned in the section describing
> ipairs nor in the section describing the # operator. I think this fact
> deserves more visibility in the manual.
The manual is very cute at saying enough, but only barely.
In this case it says
 will iterate over the key–value pairs (1,t[1]), (2,t[2]), ..., up to the
 first nil value.
The notation t[1] implies that __index is respected, the failure to
mention #t means that __len is ignored. Terse, but it has always
been like that.
You say this is actually documented in "Changes to the libraries"?
That's being absolutely verbose, then!

AltStyle によって変換されたページ (->オリジナル) /