lua-users home
lua-l archive

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



On 19 Sep 2006, at 17:20, Jerome Vuarand wrote:

   -- Simply find the highest numerical index
   local maxn = 0
   for k,v in pairs(t) do
      if type(k)=="number" and k>maxn then
         maxn = k
      end
   end

With Lua 5.1, table.maxn(t) does this (also traversing the table, but in C :-)

With regards
- Stefan