lua-users home
lua-l archive

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

Mike Pall <> wrote:
(24/02/2005 16:33)

>I wrote:
>> nt wrote:
>> > 2) Perhaps I am missing something, but there does not appear to be a 
>> > convenient way to determine if a table is empty.
>> if not next(t) then ... end
>Oops. Make that:
>if next(t) == nil then ... end
>[false is a valid key.]
>     Mike

I think those two statements work the same.
(I'm open to correction..)

Even so, I think they will only work till the next nil element in the table, There could be something beyond that point, and this wouldn't test for it.
Nor would getn, as that also works up to the first nil, unless explicitly set to a table size you tel it to be.

The way I'd solve this is to avoid having gaps in a table unless I had specific reasons for them, and knowing those reasons, to code specifically for them.

I'm out of my depth, with the subjects I've seen discussed here, but I might as well try to contribute if I think I can. >:)