Ipairs: Difference between revisions

From GiderosMobile
No edit summary
No edit summary
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
'''Available since:''' Gideros 2011.6<br/>
'''Available since:''' Gideros 2011.6<br/>
'''Class:''' [[(global)]]<br/>
=== Description ===
=== Description ===
Returns three values: an iterator function, the table t, and 0, so that the construction  
Returns three values: an iterator function, the table t, and 0, so that the construction


    `for i,v in ipairs(t) do body end`
''for i,v in ipairs(t) do '''body''' end''


will iterate over the pairs (1,t[1]), (2,t[2]), ···, up to the first integer key absent from the table.
will iterate over the pairs (1,t[1]), (2,t[2]), ..., up to the first integer key absent from the table.
<source lang="lua">
<syntaxhighlight lang="lua">
(function), (table), (any) = ipairs(t)
(function), (table), (any) = ipairs(t)
</source>
</syntaxhighlight>
 
=== Parameters ===
=== Parameters ===
'''t''': (table) indexed table to iterate through <br/>
'''t''': (table) indexed table to iterate through<br/>
 
=== Return values ===
=== Return values ===
'''Returns''' (function) iterator function<br/>
'''Returns''' (function) iterator function<br/>
'''Returns''' (table) provided table t<br/>
'''Returns''' (table) provided table t<br/>
'''Returns''' (any) value 0<br/>
'''Returns''' (any) value<br/>
 
=== See also ===
'''https://luau.org/library#global-functions'''<br/>
 
{{(global)}}

Latest revision as of 10:27, 21 July 2025

Available since: Gideros 2011.6
Class: (global)

Description

Returns three values: an iterator function, the table t, and 0, so that the construction

for i,v in ipairs(t) do body end

will iterate over the pairs (1,t[1]), (2,t[2]), ..., up to the first integer key absent from the table.

(function), (table), (any) = ipairs(t)

Parameters

t: (table) indexed table to iterate through

Return values

Returns (function) iterator function
Returns (table) provided table t
Returns (any) value

See also

https://luau.org/library#global-functions