Option Parsing: Options with Optional Arguments

All of the examples so far have illustrated options with required arguments; that is, if the option is passed, it must be followed by an argument. It’s also possible to define an option that takes an optional argument:

The last example above illustrates the problem with options that take optional arguments: there isn’t an easy way to determine whether the option was passed without an argument or the option was not passed at all. In both of these cases, the property is left at the default value (null in this case).