lua-users home
lua-l archive

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

Eva Schmidt wrote:
> For tables with string indices there is simply no length operator :-(
> So far, the only way to get a reliable information about the length
> of a table is to iterate it by using for i,v in pairs (tbl) and count
> the field by myself.  
> For me this is very dissatisfying. :-(
> Is there any way to find a length operator for tables independent of
> the type of its keys? 

You're right, there is no way to get the total number of key/value pairs
in a table.

However I can't see any use for that information which doesn't involve
building an array anyway (the size of which can be queried afterward).
Can you tell us in what situation you would need to have that
information ?