lua-users home
lua-l archive

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


Programmatically achieving the same thing.

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

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