lua-users home
lua-l archive

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

For example luajit2 (latest, 32-bit and 64-bit MSVC) returns 16.

On 3/31/2011 8:32 AM, Jan Behrens wrote:
On Thursday 31 March 2011 17:28:12 Arvid Enbom wrote:

Run this for some strange results:

According to the Lua reference manual, the length operator (#) is supposed
to return the highest consecutive numerical index. This means the above
code SHOULD return 2, because 3 is nil.

It returns 128.


"If the array has "holes" (that is, nil values between other non-nil values),
then #t can be any of the indices that directly precedes a nil value (that is,
it may consider any such nil value as the end of the array)."

Returning 128 is within specification (as well as returning 2 would be).

Jan Behrens