Confused as to how table.pack
works. Help is much appreciated.
Very simple.
table.pack(arg1, args2, ...: tuple): table
-- Returns a sequential array consisting of provided values.
local tabl = table.pack("a", "b", "c", "d")
print(#tabl) --> 4
print(tabl[1]) --> a
local equivalent = {"a", "b", "c", "d"}
print(#equivalent) --> 4
Complementary function:
table.unpack(arg: table, start: number?, final: number?): tuple
local tabl = {"a", "b", "c", "d"}
print(table.unpack(tabl)) --> a b c d
Additional arguments to table.unpack():
local tabl = {"a", "b", "c", "d"}
local startIndex = 2
local finalIndex = 3
print(table.unpack(tabl, startIndex, finalIndex)) --> b c
4 Likes
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.