lua-users home
lua-l archive

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

>> My opinion is that all proposed operators to get the length of a table
>> are
>> too cryptic to be used with a language with an intuitive syntax as
>> Lua. A
>> more intuitive length operator, at least for me, is |t|. Of course |s|
>> could also be used to get the length of a string.
>Why do we need a length operator? And anyway, how do you determine the
>length of a table? It's implementation specific. Do you count the number
>of key-value pairs, the highest numeric key, the number of numeric keys
>Look at the getn docs etc.

I don't really need a length or size operator, I just think it'll be a good thing. Roberto is proposing this new operator (, I just wanted to say to keep the language easy and intuitive.

Answering your question, for me the length of a table is one that I could use to append values to a table without worrying about overriding something that already was in the table, or, to be more specific, the highest numeric key.