lua-users home
lua-l archive

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


On Fri, 2011-04-01 at 09:35 -0300, Luiz Henrique de Figueiredo wrote:
> > Maybe we could collectively have a friendly, instructive standard answer ready?
> 
> Right! I was surprised to find that http://www.luafaq.org/ does not has this.

It has a little mention in http://www.luafaq.org/#T1.10

> In this case, #t is unreliable, since then length operator # is only
defined for non-sparse arrays (arrays without holes). If you wish to
keep track of the size of a sparse array, then it is best to keep and
increment a counter...

Also, it is mentioned in http://www.luafaq.org/gotchas.html#T6.4

> Try not to put nil in arrays. It will work if you know what you're
doing, but the length operator # will be confused and standard table
functions like table.sort() will complain bitterly...