I have this test function which simply prints values passed to it
function test1(...)
for k, v in ipairs(arg) do
print(v)
end
end
function test2(...)
for k, v in pairs(arg) do
print(v)
end
end
-- GOOD behavior
test1(1, 2, 3, 4) -- produces 1 2 3 4
test2(1, 2, 3, 4) -- produces 1 2 3 4
-- BAD behavior
test1( unpack({1,2}), 3, 4) -- produces 1 3 4
test2( unpack({1,2}), 3, 4) -- produces 1 3 4 3
Can someone explain this behavior to me ?