[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Variadic Function Call
- From: Xmilia Hermit <xmilia.hermit@...>
- Date: Sat, 30 Sep 2023 08:53:33 +0200
I know that the three dots notation '...' can be
used in function definition to mean variable arguments. My
question is: Is it legal to have the three dots _expression_
as an argument to a function call?
Yes, the three dots are allowed to be used in variadic functions
as expressions and result in the arguments passed in the variadic
part (see https://www.lua.org/manual/5.4/manual.html#3.4).
For example:
function pass_on(func, ...)
return func(...)
end
will take a function and more aguments and call the function with
all the passed arguments after the func argument.
Regards,
Xmilia