Consider the following matching:
p = Rule[_String, _String];
MatchQ[f[Rule["a", "b"], Rule["c", "d"]], f[p ..]]
(* True *)
If you replace f
with List
(or even outlandish operators like Grid
or SingularValueDecomposition
), it still matches:
MatchQ[List[Rule["a", "b"], Rule["c", "d"]], List[p ..]]
(* True *)
However, if you replace f
with Association
, it doesn't match:
MatchQ[Association[Rule["a", "b"], Rule["c", "d"]], Association[p ..]]
(* False *)
Why is this? Ordinarily I would suspect that evaluation changes the form, but calling FullForm[Association[Rule["a", "b"], Rule["c", "d"]]]
returns Association[Rule["a", "b"], Rule["c", "d"]]
, ie, its form is unchanged.
Ultimately I'd like a pattern that matches Association
s of String
s to TemporalData
s, and while trying to figure out why my pattern didn't work, I found the above minimal(ish) example.
KeyValuePattern
was introduced in V10.4, but I'm on V10.2. ARGH $\endgroup$ – Peter Richter Jan 2 '18 at 0:47