[erlang-questions] Matching Empty maps

Joe Armstrong erlang@REDACTED
Tue Feb 7 12:45:15 CET 2017


Ten minutes ago I was happily recursing down a list and discovered
to my horror that an empty map isn't an empty map.

1> #{} = #{a => 1}.
#{a => 1}

The documentation actually says:

<quote>
#{} = Expr

This expression matches if the expression Expr is of type map,
otherwise it fails with an exception badmatch.
</quote>

So #{} is an empty map in an argument position but not an empty map
in a pattern.

So this is not a bug since the system does what the documentation says
but it is very weird.

Is there some deep reason for this that I've missed ??????

Very Puzzled

/Joe



More information about the erlang-questions mailing list