dealing with types in kwargs in Julia
问题 How can I use kwargs in a Julia function and declare their types for speed? function f(x::Float64; kwargs...) kwargs = Dict(kwargs) if haskey(kwargs, :c) c::Float64 = kwargs[:c] else c::Float64 = 1.0 end return x^2 + c end f(0.0, c=10.0) yields: ERROR: LoadError: syntax: multiple type declarations for "c" Of course I can define the function as f(x::Float64, c::Float64=1.0) to achieve the result, but I have MANY optional arguments with default values to pass, so I'd prefer to use kwargs.