[erlang-questions] Illegal map key in pattern
Valentin Micic
v@REDACTED
Sat Aug 3 18:14:15 CEST 2019
Hi,
I am a bit nonplussed with the behaviour of map module…consider the following map:
f(MAP), MAP = #{ {12,1} => "some value", {12,2} => "some other value"}.
Then, the following works:
f(V), case MAP of #{ {1,12} := V} -> V end.
"some value”
Then, surely, a snippet below should also work... except that it doesn’t:
f(DCID), f(SORD), DCID = 12, SORD=1.
f(V), case MAP of #{ {DCID, SORD} := V} -> V end.
* 1: illegal map key in pattern
To make things worse, when I just replace an explicit term, such as {DCID, SORD}, with something like this:
f(GRP_KEY), GRP_KEY={DCID, SORD}.
f(V), case MAP of #{ GRP_KEY := V} -> V end.
"some value”
Then the whole thing works again.
I would argue that all cases should just work.
How come they don’t?
Kind regards
V/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190803/d6478966/attachment.htm>
More information about the erlang-questions
mailing list