lua-users home
lua-l archive

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


The solution I've found is to have a 'n' field on the
table, and update it when I insert a new entry on the
table:

local mytable = { n = 0 }


for i = 1, readInfoCount()
   local name, info

   name, info = readInfo(i)

   mytable[name] = info

   mytable.n = mytable.n + 1

end


print(mytable.n)

Will print the number of members of the table,
alright, but the problem is if I have a field named
like "n"...

I could use _n, tableSize or other name to keep the
table size, but I wonder if there is one clever way of
do this...

Anyway, thank you all for the tips!

Another question is if it's possible to get a table
field using an index, on a non numerical indexed
table.

Yes, I could use foreachi ... but there is a direct
way of do this?





__________________________________________________
Converse com seus amigos em tempo real com o Yahoo! Messenger 
http://br.download.yahoo.com/messenger/