Reproduction Steps
In Roblox Studio run the following command in the command line:
print({
unpack({"a", "b", "c", "d", "e", "f", "g", "h", "i"}),
unpack({"easy", "as", "one", "two", "three"})
})
Expected Behavior
I would expect the following in the output:
▼ {
[1] = "a",
[2] = "b",
[3] = "c",
[4] = "d",
[5] = "e",
[6] = "f",
[7] = "g",
[8] = "h",
[9] = "i",
[10] = "easy",
[11] = "as",
[13] = "one",
[14] = "two",
[15] = "three"
} - Edit
Every item in the first unpacked list is added to the new list in order and every item in the second unpacked list is added sequentially where the first list left off.
Actual Behavior
What I get instead:
▼ {
[1] = "a",
[2] = "easy",
[3] = "as",
[4] = "one",
[5] = "two",
[6] = "three"
} - Edit
Only the first item of the first list was added to the new list but every item of the second list was added sequentially after that.
Workaround
This is the best way I’ve found of combining two or more lists. It’s kind of messy and I wish I didn’t need to define a function for this.
function CombineLists(... : table)
local Output = {}
local i = 1
for x, list in ipairs({...}) do
for y, item in ipairs(list) do
table.insert(Output, i, item)
i = i + 1
end
end
return Output
end
Issue Area: Engine
Issue Type: Other
Impact: Low
Frequency: Rarely