6

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 ?

1
  • Well sadly no it doesn't work (I'm using love2D) Commented Aug 26, 2017 at 9:48

3 Answers 3

2

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

Sign up to request clarification or add additional context in comments.

Comments

2

You could use intermediate results

local a, b = f1()
f2(a, b, c)

Comments

1

You can use a table as a helper:

tbl={f1()}
tbl[3]=c
f2(unpack(tbl))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.