WORKFLOW
Define a Function with Options
Use options in user-defined functions.
Define a function’s options
Define the options for a function named shout, giving the options’ default values:
Define the function, including OptionsPattern[] as the last argument
Begin the definition of the shout function, giving OptionsPattern[] as the last argument. OptionsPattern[] indicates that options can occur in that position:
Refer to option values in the function body
Complete the function definition, referring to option values in the body of the function with OptionValue:
- OptionValue may be used anywhere in the body of a function.
Use the function’s options
Invoking the function without options uses the default values of the options:
Give options to change the defaults: