-- print all values of array 'a' for i,v in ipairs(a) do print(v) end -- print all keys of table 't' for k in pairs(t) do print(k) end function newCounter() local i = 0 return function() i = i + 1 return i end end c1 = newCounter() print( c1() ) --> 1 print( c1() ) --> 2