If I want to set default values to arguments of a function, in the simplest case I can write
f[a_:1,b_:2]:={a,b}
and it is OK:
f[10]f[]
{10,2}
{1,2}
But if I want to add some options
g[a_:1,b_:2,opts___]:={a,b,c/.{opts}}
it works in this case
g[10,20,c30]
{10,20,30}
but here I have a problem:
g[10,20]
ReplaceAll::reps:{20} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing.
{10,2,c/.{20}}
instead of {10,20,c} and here
g[10]
ReplaceAll::reps:{10} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing.
{1,2,c/.{10}}
instead of {10,2,c}. How to solve this problem?