Table.pack

From GiderosMobile
Revision as of 14:33, 13 July 2023 by Hgy29 (talk | contribs) (Text replacement - "</source>" to "</syntaxhighlight>")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Available since: Gideros 2022.3
Class: table

Description

Returns a new table with all arguments stored into keys 1, 2, etc. and with a field "n" with the total number of arguments.

(table) = table.pack(values...)
Note: the resulting table may not be a sequence

Parameters

values...: (any) value to fill the table with

Return values

Returns (table) the newly created table and table.n with the total number of arguments

Example

local t = table.pack(1, 2, 3)
print(table.concat(t, ", ")) --> 1, 2, 3
print(t.n) --> 3