lua-users home
lua-l archive

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


The only way I know to count non-indexed values in a table is like this:

function countFields(t)
 local count = 0
 for k, v in pairs(t) do
   count = count + 1
 end
 return count
end

Does anyone have a better solution?

--
Matt Campbell
Lead Programmer
Serotek Corporation
www.freedombox.info
"The Accessibility Anywhere People"