Type Function Library (globals) Return value (varies) Revision Release 2024.3703 Keywords pairs, tables, next, loops, iteration See also pairs() next()
This function returns three values: an iteration Function, a Table, and 0
. For example, the following construction will iterate over the pairs (1,t[1])
, (2,t[2])
, ...
, up to the first integer key absent from the table.
for i,v in ipairs( t ) do --code end
ipairs( t )
Table. The table that is to be iterated.
local t = { "every", "word", "is", "on", "a", "separate", "line." } for i,v in ipairs(t) do print( v ) -- print each array element on a separate line end