Passing arguments to other function (equivalent of R's "...")

Is there any way of passing undefined arguments to a function within a function?

I’ve tried with kwargs... but it seems that I’m doing something wrong…

function f(x::Number; a=1, b=2, c=3, d=4)
  return(x+a+b+c+d)
end


function f(x::Vector; kwargs...)
  out = f.(x, kwargs...)
end


f(1) # works
f([1, 2]) # works
f([1, 2], c=6) # Doesn't work

Note the ;

julia> function f(x::Number; a=1, b=2, c=3, d=4)
         return(x+a+b+c+d)
       end
f (generic function with 1 method)

julia> function f(x::Vector; kwargs...)
         out = f.(x; kwargs...)
       end
f (generic function with 2 methods)

julia> f([1, 2], c=6)
2-element Array{Int64,1}:
 14
 15
2 Likes

That was subtle, thanks :grin: