Difference between revisions of "Unpack"
From GiderosMobile
m (Text replacement - "<source" to "<syntaxhighlight") |
|||
(One intermediate revision by the same user not shown) | |||
Line 7: | Line 7: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
(multiple) = unpack(list) | (multiple) = unpack(list) | ||
− | </ | + | </syntaxhighlight> |
− | + | ||
+ | The function is equivalent to | ||
return list[i], list[i+1], ···, list[j] | return list[i], list[i+1], ···, list[j] | ||
except that the above code can be written only for a fixed number of elements. By default, i is 1 and j is the length of the list, as defined by the length operator. | except that the above code can be written only for a fixed number of elements. By default, i is 1 and j is the length of the list, as defined by the length operator. | ||
Line 18: | Line 19: | ||
=== Return values === | === Return values === | ||
'''Returns''' (multiple) all values from table as separate values<br/> | '''Returns''' (multiple) all values from table as separate values<br/> | ||
+ | |||
+ | === See also === | ||
+ | '''https://luau.org/library#global-functions'''<br/> | ||
{{(global)}} | {{(global)}} |
Latest revision as of 12:29, 21 July 2025
Available since: Gideros 2011.6
Class: (global)
Description
Returns the elements from the given table.
(multiple) = unpack(list)
The function is equivalent to
return list[i], list[i+1], ···, list[j]
except that the above code can be written only for a fixed number of elements. By default, i is 1 and j is the length of the list, as defined by the length operator.
Parameters
list: (table) table from which to extract elements
Return values
Returns (multiple) all values from table as separate values
See also
https://luau.org/library#global-functions