I don't understand the output from:
Remove[g];
Options[g] = {"asd" -> 2};
g[a_, Optional[z_?Positive, 1], OptionsPattern[]] := {a, z, OptionValue["asd"]}
g[2, {}, "asd" -> 4]
{2, 1, 4}
The documentation of PatternTest says:
Any result for test[pval] other than True is taken to signify failure
but Positive[{}] =!= True
holds, so it appears that the { }
argument is interpreted as an option although the head is not Rule
. I'm not sure how this should be fixed because I don't understand why it is wrong as it stands. What am I missing?
g[2, {}, "asd" -> 4]
$\endgroup${}
failsPositive
test so optional1
is used, what is the problem? Sorry if I missed something $\endgroup$