pairs(t)
Returns three values: the next function, the table
t, and null, so that
the constructionfor k,v in pairs(t) do body end
will iterate
over all key–value pairs of table t.See function next for the caveats of modifying the table during its traversal.
Example
sum = 0
t = { 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 }
for key, value in pairs(t) do
if key % 2 == 0 then
sum = sum + value
end
end