OptionValue
[name]OptionsPattern
.OptionValue
[f, name]OptionValue
[f, optvals, name]OptionValue
[..., list]f[a->3] /. f[OptionsPattern[{}]] -> {OptionValue[a]}
Unavailable options generate a message:
f[a->3] /. f[OptionsPattern[{}]] -> {OptionValue[b]}
The argument of OptionValue
must be a symbol:
f[a->3] /. f[OptionsPattern[{}]] -> {OptionValue[a+b]}
However, it can be evaluated dynamically:
f[a->5] /. f[OptionsPattern[{}]] -> {OptionValue[Symbol["a"]]}