lua-users home
lua-l archive

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


Asko Kauppi wrote:
> 1. Is #t NOT expected to work, if a table has both integer (1..N) and  
> other (string, etc) keys?

Sorry, my wording was too ambiguous.

Of course #t always 'works' in the sense that it finds the
maximum positive integral key for arrays without holes. It
doesn't matter if there are other keys, too:

 print(#{ 0, [1.5]=0, 0, [2.5]=0, foo=0 }) --> 2

My point was that newbies could easily be lead to the wrong
conclusion that table.maxn is the standard way to get the length
of a table. But it's only a fallback for exceptional cases.