lua-users home
lua-l archive

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


The # operator will work as expected only when the tables are
well-formed arrays (which means that #t == n implies that values at
indices 1 to n are NOT nil and that the value at index n+1 IS nil. In
your case the indices are actually strings (besides the fact that they
don't start at 1). The fact that you consider this to be an oddity
means that you most probably need to read the manual on this issue
very carefully.

Cheers,
Varol Kaptan

On 1/23/07, Jimmie Houchin <jhouchin@cableone.net> wrote:
I have had this happen a couple of times to me.
I don't know if this how it is supposed to be and I am misunderstanding
something.

 > =items
table: 0x807e760
 > printt(items)
0007126409      table: 0x8089bf0
0007164653      table: 0x80abf38
000215949X      table: 0x80ea8f0
0007157207      table: 0x80f52f0
000100039X      table: 0x80d3458
0007145160      table: 0x80d5348
0007744684      table: 0x80da320
0007133103      table: 0x80d9290
0007104065      table: 0x8092438
0007161069      table: 0x8096cc8
 > =#items
0
 >

I got tired of doing
for k,v in pairs(t) do print(k,v) end
so I assigned it to printt(t). :)

So I don't understand why I am getting a size of 0 for a table of 10 items?

Also I have lots of tables indexed by strings of digits as above.
But if I try to access them via

 > =items.0007126409
stdin:1: '<eof>' expected near '.0007126409'

doesn't work, but this does.

 > return items['0007126409']
table: 0x8089bf0

Any help understanding what I'm currently not understanding would be
greatly appreciated.

Thanks.

Jimmie