gives the value of name for options associated with the head f.
extracts option values from the explicit list of rules opts.
extracts several option values.
- OptionValue[name] is equivalent to OptionValue[f,name], where f is the head of the left-hand side of the transformation rule in which OptionValue[name] appears.
- OptionValue[f,name] and OptionValue[name] will use values from the first OptionsPattern object that appears as an argument of f.
- In OptionValue[f,opts,name], only the explicit list opts and the defaults derived from f will be considered.
- In OptionValue[f,opts,name], f can be a symbol, a rule, or a list of symbols and rules specifying default values. Each symbol s in f is equivalent to Options[s]. If the same option name is specified multiple times, the first specification determines the default.
- OptionValue[f,opts,name,Hold] returns the option value with Hold wrapped around it.
- OptionValue[Automatic,Automatic,name,Hold] is equivalent to OptionValue[name], except that the option value is returned with Hold wrapped around it.
- OptionValue ignores contexts when comparing option names and treats the symbol s and the string SymbolName[s] interchangeably.
Examplesopen allclose all
Basic Examples (1)
Define a transformation rule using multiple OptionsPattern constructs:
OptionValue tracks where a particular option was specified:
Properties & Relations (4)
OptionValue checks that all options requested appear in the defaults:
However, OptionValue performs additional normalization to ensure rules are correctly applied: