Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What does unpacking and packing a table do?

Asked by 5 years ago

I could not find a good answer online, what does table.pack and table.unpack do?

1 answer

Log in to vote
2
Answered by
gullet 471 Moderation Voter
5 years ago
Edited 5 years ago

Unpack returns all the elements of the table as separate values: {1, 2, 3} becomes 1, 2, 3 Pack doesn't exist in Lua 5.1 (which Roblox uses).

local t = {1,2,3}
print(t)
print(1, 2, 3)
print(unpack(t))

Output

table: internal_id
1 2 3
1 2 3
Ad

Answer this question