I want to know if I can pass a table as a parameter of an API function and have it modified there or if I have to utilize return values:
Will
local table = { [1] = "foo" } api.makeBar(table) print(table[1])
with api.makeBar(param) being
function makeBar(param) param[1] = "bar" end
print "foo" or "bar" as the result?
EDIT: By testing, I found out that Lua indeed is pass-by-reference (the above code outputs "bar".)
Is this consistent or undefined behaviour?
Edited by MrObsidy, 24 April 2019 - 06:21 PM.