title: Pattern match function against empty map
body: <p>I'm playing around with pattern match and I found out, that it's not quite easy to pattern match parameters of a method against an empty map. I thought it would go something like this:</p>
  <pre class="lang-elixir prettyprint-override"><code>defmodule PatternMatch do
    def modify(%{}) do
      %{}
    end
  
    def modify(map) do
      # expensive operation
      %{ modified: &quot;map&quot; }
    end
  end
  </code></pre>
  <p>But it seems like the first function clause matches arbitrary maps:</p>
  <pre class="lang-bash prettyprint-override"><code>iex&gt; PatternMatch.modify(%{a: &quot;map&quot;})
  ==&gt; %{}
  </code></pre>
  <p>Is there another way to check for empty maps?</p>