TypeFunction Library(globals) Return value(elements of given table between `i`

and`j`

)RevisionCurrent Public Release (2018.3326) Keywordsunpack, global

Returns the elements from the given table. This function is equivalent to the following:

return list[i], list[i+1], ..., list[j]

The difference is 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 (`#`

).

unpack( list [, i [, j ]] )

*Table.* The table whose elements will be unpacked.

*Number.* The index of the table element at which the function will begin unpacking values. Default is `1`

.

*Number.* The index of the table element at which the function will stop unpacking values. Default is the length of the given table provided by the length operator (`#`

).

local t = { [1] = "first", [2] = "second", [3] = "third", [4] = "fourth", [5] = "fifth" } local two, three, four = unpack( t, 2, 4 ) print( two, three, four ) -- OUTPUT: second third fourth