lua-users home
lua-l archive

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


> On 16-06-30 05:11 PM, Tim Hill wrote:
>>> What about {1, [3]=3, 2} ? {1, [2]=2, 2} ? etc
>> 2 and 2. The largest implicit key. As I said, this is the *least* surprising, not that it has no surprises at all.

I'm confused; are we talking about existing or desired behavior? The
following prints "3 3 3" in Lua 5.2, Lua 5.3 and LuaJIT for me and
this is what I'd expect:

print(#({1, 2, [3]=3}), #({1, [3]=3, 2}), #({[3]=3, [2]=2, 1}))

> Huh. And what length of sequence should be after
> local t = {1, [2]=2, 2}
> table.remove(t, 2)

I'd expect #a to be 1 and this is how it's reported by Lua 5.1-5.3.

BTW, "({1,2,[2] = 0})[2]" is 2 in Lua 5.2 and 5.3, but is 0 in LuaJIT
(I tend to favor seeing 0 in this case).

Paul.