I am trying to understand the most Julia way to create a function that specifies some default parameters that can also be modified by inputing external parameters.
pars = default_pars() would return all the default parameters.
pars = default_pars(a=8., b=7.)would return all default parameters but would in addition set a new value for parameters a and b.
Below is a Python example of what I have in mind.
Thanks.
def default_pars(**kwargs):
pars = {}
pars['a'] = 1.
pars['b'] = 2.
pars['c'] = 3.
# external parameters if any
pars.update(kwargs)
return pars
The main way to do this is with what are called keyword arguments. There is also a package that offers addition functionality for more complicated cases: