WLJS LogoWLJS Notebook

OptionValue

OptionValue[name] extracts option values inside a function defined with OptionsPattern[].

Examples

Define functions with options:

Options[myFunc] = {Color -> Red, Size -> 10}

myFunc[x_, OptionsPattern[]] := {
  OptionValue[Color],
  OptionValue[Size],
  x
}

myFunc[5]
(* {Red, 10, 5} *)

myFunc[5, Color -> Blue]
(* {Blue, 10, 5} *)

Please visit the official Wolfram Language Reference for more details.

On this page