Function with OptionsPattern

I define a function:

func3[a_,OptionsPattern[$opt1->False]]:=Module[{junk}, Print[OptionValue[$opt1]]]

It works as expected when invoked as:

func3["abc",$opt1->True]

But, if I type:
Options[func3] I get ‘{}’ as the response rather than (as I expected) ‘{$opt1->False}’

If I type:
Options[Plot] or any other system function

I get the options for the system function.
The docs for Options don’t mention any restrictions the function specified. But, I can’t get it to work for any of my (user) functions.

I’ve never used OptionsPattern that way. I always declare the options list for my function and then use OptionsPattern with no arguments (I also never see option symbols that have a $ in the name, that’s usually used to mark a constant or a setting you can reset):

Options[func3] = {opt1 -> True}
func3[a_, OptionsPattern\[\]\] := Module[{}, Print[OptionValue[opt1]]]

Then Options[func3] will return your options list and OptionValue inside the function will be able to look up the options for func3.

Thanks much, your suggestion worked as advertised. Being a newbie to Mathematica, I suspect I will do a lot of things that you (and others) haven’t seen before.

Glad to help!

Looking at the documentation to remind me, the OptionsPattern you used is for supplying an on-the-fly list of defaults, which I’ve seen used to implement “hidden options” (a.k.a. undocumented options), i.e. options that don’t show up when you evaluate Options[f].