matching on maps

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


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?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the erlang-questions mailing list