lua-users home
lua-l archive

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


Leo Razoumov wrote:

How can one easily find out the number of records stored
in a table?  I think that there should be a convenient
idiom for such a common task.

As lhf pointed out, it's surprisingly uncommon (given what a
basic idea it is).  Here's how to do it:

local Count = 0
for _ in pairs(Tbl) do Count = Count + 1 end

--
Aaron