You can't pattern match on a HashDict. In general, when you see something printed as #HashDict<...>
it is exactly because its internal representation is "private". Maps are coming on Elixir 0.13 and they will support pattern matching (and other goodies).
How to do patternmatching against HashDict in elixir?
-
12-10-2022 - |
Question
How can I do pattern matching against HashDict in Elixir? I can not find any decent information anywhere. So example I have is and it is bound to variable a:
#HashDict<[{"a", 1}, {"b", 2}]>
And lets say I want to get 2
I tried something like this to test a concept, but no luck:
[{"a",1}, {"b",val} = a
But I get: (MatchError) no match of right hand side value
Can someone help me with this?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow