[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: How to determine true size of a table?
- From: Chris <coderight@...>
- Date: Thu, 2 Mar 2006 11:33:17 -0500
On 3/2/06, Matt Campbell <email@example.com> wrote:
The only way I know to count non-indexed values in a table is like this:
local count = 0
for k, v in pairs(t) do
count = count + 1
Does anyone have a better solution?
Yes, hopefully there is a better way to do this as that has a lot more
overhead (especially on large arrays). Since I figure
internally Lua at least knows the number of items in the hash
table I'm wondering how to get to that value (which should be at least
as fast as the length operator).