OptionValue

WMA link


OptionValue[name]

gives the value of the option name matched by OptionsPattern.

OptionValue[f, name]

recover the value of the option name associated with the head f.

OptionValue[f, opts, name]

recover the value of the option name associated with the symbol f, extracting the values from optvals if available.

OptionValue[..., list]

recover the value of the options in list .

First, set up a symbol with some options using Options:

Now get a value previously set:

If the option does exist we get a message:

Use OptionValue to get the value of option a inside OptionsPattern a->3

An unavailable option returns argument and does not generate a message:

The argument of OptionValue must be a symbol:

However, the symbol can be evaluated dynamically:

See also Options and OptionsPattern.

OptionQ
Options