'clojure.core.match on nested map
in clojure.core.match , this example works well in nested map
(match [{:a {:b :c}}]
[{:a {:b nested-arg}}] nested-arg)
but when change the key to a vector it will raise error.
(m/match x
{:a {[:b :c] 1}}
:found
)
Isn't that [:b :c] is a valid key in clojure map ? Or it just won't work in clojure.core.match ?
Solution 1:[1]
[:b :c] is of course a valid key. This is a bug and it was already reported, see opened issue.
And it seems you can't also match map with numbers as keys:
(match/match [{:a 4}]
[{:a _}] :found)
=> :found
(match/match [{2 4}]
[{2 _}] :found)
Unexpected error (ClassCastException) macroexpanding match/match at ....
class java.lang.Long cannot be cast to class clojure.lang.Named (java.lang.Long is in module java.base of loader 'bootstrap'; clojure.lang.Named is in unnamed module of loader 'app')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Martin Půda |
