Hello,
Let these two functions:
function f(x, a, b)
return b*(x+a)
end
function g(args....)
return f(1, args...)
end
If we run g(2,3)
, we get f(1, 2, 3)
.
Is there a way to do g(b=3, a=2)
and get the same result? Not sure I’m clear…
Hello,
Let these two functions:
function f(x, a, b)
return b*(x+a)
end
function g(args....)
return f(1, args...)
end
If we run g(2,3)
, we get f(1, 2, 3)
.
Is there a way to do g(b=3, a=2)
and get the same result? Not sure I’m clear…
f(1; args...)
put a semi-colon so they go to the keyword arguments.
But first you must redefine f
to take keyword arguments.
Ok, I found. This is not enough. I have to define f(x; a, b)
and g(; args...)
. Right?
Yes