[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Newbie: ipairs() for tables with non integer keys
- From: "Ganesh Gunasegaran" <ganesh.gunasegaran@...>
- Date: Fri, 8 Dec 2006 12:08:35 +0530
Hi,
Does ipairs() work only with integer keys? if so why?
student = {}
student.name = "Test"
student.age = 25
for i,v in ipairs(student) do -- A
print(i,"=>",v)
end
test_arr = {4,5,6}
for i,v in ipairs(test_arr) do -- B
print(i,"=>",v)
end
#########################
---------- Run ----------
1 => 4
2 => 5
3 => 6
Output completed (0 sec consumed) - Normal Termination
I expected that the for loop at A to print something like
"name" => "Test"
"age" => 25
Cheers,
GG