[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: create list start from index 0 with table
- From: "Ong hean kuan" <mysurface@...>
- Date: Mon, 23 Jun 2008 18:22:27 +0800
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)
end
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?
Regards,
--
Hean Kuan Ong
http://linux.byexamples.com
http://cc.byexamples.com
http://wordpress.byexamples.com