lua-users home
lua-l archive

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

By default list constructed from table will start with index 1. I can force it to start at any value, such as 0 like this:

t = { [0]='a','b','c','d','e','f' }

But when i try to loop and access the item one by one, it seems to act strange:

My for loop:
for i,v in pairs(t) do
    print (i," = ", v)

The Result:
1        =      b
2        =      c
3        =      d
4        =      e
5        =      f
0        =      a

Instead of make 0 as first index of for loop, it place it as the last item.

My question is:
Is there any ways to make index 0 appear as 1st?

Hean Kuan Ong