lua-users home
lua-l archive

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


Hello.

Run this for some strange results:
print(#{[1]=1,[2]=1,[4]=1,[8]=1,[16]=1,[32]=1,[64]=1,[128]=1})

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.

The bug only worked for me if I defined the entire table manually, and it only occurred if each index is twice as large as the one before it. The values didn't matter.