title: cond and pattern matching against map
body: <p>In a phoenix app, when a user submit a specific form, lat and lng are calculated from address. </p>
  
  <p>The lat and lng can be in changeset.data if no changes are made and in changeset.changes if changes are submit. </p>
  
  <p>I perform other stuff on lat and lng on the changeset but I need to know where the coordinates are. What I'm trying to do is: </p>
  
  <pre><code>cond do 
    # Always use new coordinates if possible
    %{lat: lat, lng: lng} = changeset.changes -&gt;
      do_something(lat, lng)
    %{lat: lat, lng: lng} = changeset.data -&gt;
      do_something(lat, lng)
    true -&gt;
      do_nothing_and_return_the_changeset_as_is
  end
  </code></pre>
  
  <p>Of course this is not working because it's not returning <code>true</code> or <code>false</code> on pattern not matching. </p>
  
  <p><code>** (MatchError) no match of right hand side value: %{lat: any_value}</code></p>
  
  <p>I actually made a long not looking good if else if .... statement to achieved this.</p>
  
  <p>Is there a better elixir way of doing this? </p>