matching on maps

Andreas Schultz andreas.schultz@REDACTED
Wed May 13 15:08:52 CEST 2020


Hi,

In the OTP-23 blog entry, there is an example of a illegal map match:

  illegal_example(Key, #{Key := Value}) -> Value.

Can someone explain why the compiler couldn't automatically rewrite that to:

   legal_example(Key, Map) when is_map_key(Key, Map) -> maps:get(Key, Map).

Such a rewrite should be possible whenever there are further restrictions
(matches or guards) on the content of Value, right?

Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20200513/add3af21/attachment.htm>


More information about the erlang-questions mailing list