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]– MeMyselfI Feb 01 '19 at 14:35{}failsPositivetest so optional1is used, what is the problem? Sorry if I missed something – Kuba Feb 01 '19 at 14:39