title: Pattern matching map with optional keys
body: <p>I have a function which receives a map with many keys, some of them are optional. How can I write the function signature comprehending the map while allowing the optional keys to default to something?</p>
  
  
  
  <pre class="lang-rb prettyprint-override"><code>def handle_my_map(%{text: text, 
                      print_times: print_times, # this I want to default to 2
                      color: color # this I want to default to "Blue"
    }) do
    Enum.each(1..print_times, fn (_) -&gt; IO.puts ["(", color, "): ", text] end)
  end
  
  Test.handle_my_map(%{text: "here", print_times: 5, color: "Red"})
  # (Red): here
  # (Red): here
  # (Red): here
  # (Red): here
  # (Red): here
  
  handle_my_map(%{text: "there"})
  # =&gt; MatchError!
  </code></pre>
  
  <p>I would like it to be:</p>
  
  <pre class="lang-rb prettyprint-override"><code>handle_my_map(%{text: "where", print_times: 3})
  # (Blue): where
  # (Blue): where
  # (Blue): where
  handle_my_map(%{text: "there"})
  # (Blue): there
  # (Blue): there
  </code></pre>
  
  <p>Something like ruby's keyword arguments:</p>
  
  <pre class="lang-rb prettyprint-override"><code>def handle_my_map(text: nil, print_times: 2, color: 'Blue')
  </code></pre>