I want to do something like
foo[OptionsPattern[]] := OptionValue[b]
Options[foo] = {a -> 0, b :> OptionValue[a]};
foo[a -> 1]
and have Mathematica give me 1
, instead of 0
. Is there a better way to do this than
foo[OptionsPattern[]] := (
Options[foo] = {a -> 0, b :> OptionValue[a]};
OptionValue[b]
)
foo[a -> 1]
?
For one thing, it's inefficient to set the options of foo
on every call, especially if foo
has many options.