lua-users home
lua-l archive

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

> It seems to not behave in accordance with the Lua 5.0 docs:
>   t = {}
>   table.insert(t, "a")
>   t[1] = nil
>   print (table.getn(t))
> > 1

>From the docs:

  table.insert (table, [pos,] value)

  Inserts element value at position pos in table, [...]
  This function also updates the size of the table by
  calling table.setn(table, n+1).

  table.getn (table)

  Returns the size of a table, when seen as a list. [...]
  if there was a previous call to table.setn over this table,
  the respective value is returned.

-- Roberto