functionluareturnargumentsmultiple-arguments

Lua return multiple values as arguments


I have a function (that I cannot change) returning multiple values :

function f1()
    ...
    return a, b
end

and another function (that I cannot change) taking multiple arguments :

function f2(x, y, z)
    ...
end

is there a way to do :

f2(f1(), c)

and have x be a, y be b and z be c ?


Solution

  • You can't do it in one line because f2(f1(),c) adjusts the results returned by f1 to a single value.