lua-users home
lua-l archive

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



Jason Clow wrote:
This has been annoying me for a long time...

What is the purpose/point of the "n" that pops up in tables after calling tinsert and tremove? I wouldn't mind so much if was in -every- table, but it's not. So, I never use it, since I may not know if a table has had a value added to it "manually", or with tinsert(). I must always use getn(). For a minute, I though "n" kept track of the number of entries in a table, but it doesn't! (-That- would be useful) It does exactly what getn() does, except that it's not guaranteed to be present in the table...

IMHO, it's useless, redundant, and just forces me to add extra code to ignore it.

I think it's there so you don't have to recalculate the size of the "array" each time getn() is called. It might be nice if lua tables stored there number of elements internally though...

Steve