[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Newbie questions regarding luasocket, tables
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Tue, 8 May 2007 07:16:41 -0300
> 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