Ellipsis (splatting) with named arguments


Let these two functions:

function f(x, a, b)
  return b*(x+a)

function g(args....)
  return f(1, args...)

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.

1 Like

But first you must redefine f to take keyword arguments.

1 Like

Ok, I found. This is not enough. I have to define f(x; a, b) and g(; args...). Right?

1 Like