I am experimenting with the following lua code:
function test() return 1, 2 end
function test2() return test() end
function test3() return test(), 3 end
print(test()) -- prints 1 2
print(test2()) -- prints 1 2
print(test3()) -- prints 1 3
I would like test3 to return 1, 2, 3
What is the best way to achieve this?
you could do something like this if you aren't sure how many values some function may return.
function test() return 1, 2 end
function test2() return test() end
function test3()
local values = {test2()}
table.insert(values, 3)
return unpack(values)
end
print(test3())
this outputs:
1 2 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With