Could somebody explain to me why table.unpack()
returns the first table element only when it is used in a function call with additional parameters after table.unpack()
?
Here is some demo code:
local a = {1,2,3,4,5}
print("Test", table.unpack(a)) -- prints "Test 1 2 3 4 5"
print(table.unpack(a), "Test") -- prints "1 Test"
I don't understand why the second line just prints 1 Test
. I'd expect it to print 1 2 3 4 5 Test
. Can somebody explain this behaviour? I'd also be interested in how I can make the second call to print 1 2 3 4 5 Test
.