lua-users home
lua-l archive

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


> It seems like there is no quick way to determine the number key-value
> pairs in an associative table (short of iterating through and counting
> them all).  If I am not missing something, why is there no quick way
> to determine the number of key-value pairs in an associative table?

Because it's not a frequent need. Actually, I've never needed to know how
many key-value pairs there are when I'm not using an array (ie, indexed by
natural numbers).

> Perhaps the C implementation of Lua counts the number of pairs as they
> are added and removed, but this count is not exposed in Lua?

No, it does not. See
	http://www.lua.org/source/5.1/lobject.h.html#Table

--lhf