lua-users home
lua-l archive

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


On 12/11/2010 04:18 PM, Eric Man wrote:
Programmatically achieving the same thing.

for i=1, 3, 1 do
if t == 2 then
t[i] = nil
else
t[i] = i
end
end

Nope.

Lua 5.2.0 (alpha)  Copyright (C) 1994-2010 Lua.org, PUC-Rio
> local t = { }; t[1] = 1; t[3] = 3; print(#t)
1
> local t = {1, nil, 3}; print(#t)
3
>


On 11/12/2010, at 5:38 PM, Richard Hundt wrote:

On 11/16/2010 02:15 PM, Luiz Henrique de Figueiredo wrote:

This release candidate will be the alpha version if no glitches are
found
in the next 10 days or so.

One thing I've noticed is that although one can create a sparse table
using literal syntax:

local t = { 1, nil, 3 }

there doesn't seem to be a programmatic way of achieving the same
thing. Would it be possible to add support for:

local t = { }
table.insert(t, 1)
table.insert(t, nil)
table.insert(t, 3)

and have it do the same thing?

Cheers,
Richard