lua-users home
lua-l archive

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


I can confirm that it does work with Lua-5.4.6 but doesn't with Lua-5.3.6.

====

t1 = {nil,"test"}
t2 = {true,nil,"test"}
table.remove(t2,1)
print(table.unpack(t1))
print(table.unpack(t2))

====

On 16/7/23 10:20, Milind Gupta wrote:
Hello,
        I ran into this problem with table.unpack. I am using Lua 5.3.5 and I see this:

Lua 5.3.5  Copyright (C) 1994-2018 Lua.org, PUC-Rio
> t1 = {nil,"test"}
> t2 = {true,nil,"test"}
> table.remove(t2,1)
true
> table.unpack(t1)
nil     test
> table.unpack(t2)
>

So specifically after removing the 1st element using table.remove the table.unpack does not return anything even though t1 and t2 have the same values.

Is this expected behavior? Are there any guidelines how to unpack an array with nil values?

Thanks,
Milind