Referring to the manual, I can define a function like this:
function f(x; y=0, kwargs...)
###
end
Making it somewhat more complex:
function f(x,args...; y=0, kwargs...)
###
end
If I need a specific type for the arguments, I write:
function f(x::Int64,args::Float64...; y::Int64=0, kwargs::Float64...)
###
end
this is valid for the x, args and y arguments but not for kwargs, as I get an error when I try:
julia> f(1,1.1,1.2;y=9,x=3.6,g=5.6)
ERROR: MethodError: no method matching #f#49(::Int64, ::Base.Iterators.Pairs{Symbol,Float64,Tuple{Symbol,Symbol},NamedTuple{(:x, :g),Tuple{Float64,Float64}}}, ::typeof(f), ::Int64, ::Float64, ::Float64)
Closest candidates are:
#f#49(::Int64, ::Float64, ::Any, ::Int64, ::Float64...) at REPL[193]:3
Stacktrace:
[1] (::getfield(Main, Symbol("#kw##f")))(::NamedTuple{(:y, :x, :g),Tuple{Int64,Float64,Float64}}, ::typeof(f), ::Int64, ::Float64, ::Vararg{Float64,N} where N) at .\none:0
[2] top-level scope at none:0
So how do I specify the type of variable keyword arguments?