lua-users home
lua-l archive

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


I found some discrepancies between LuaJIT (2.1.0-beta3) and Lua 5.1.5 regarding the length (#) operator that I cannot understand.

Consider:


local a = {1, nil, nil, 2, nil, 3, nil, 4}
print(#a)

In both LuaJIT and Lua 5.1.5 the result is 8 (as expected).

This instead:

local a = {1, nil, 2, nil, 3, nil, 4}
print(#a)

Lua 5.1.5 gives 7 as result, LuaJIT gives 1. Is there a logic I cannot see?

Thanks