title: Ruby remove duplicate entries in array of hashes but based on more than one value
body: <p>I've seen numerous questions about this but only with one key, never for multiple keys. </p>
  
  <p>I have the following array of hashes:</p>
  
  <pre><code>a = [{:name=&gt;"Yes, Yes, Yes", :artist=&gt;"Some Dude", :composer=&gt; 'First Dude', :duration=&gt;"3:21"},
   {:name=&gt;"Chick on the Side", :artist=&gt;"Another Dude", :duration=&gt;"3:20"},
   {:name=&gt;"Luv Is", :duration=&gt;"3:13"},
   {:name=&gt;"Yes, Yes, Yes", :artist=&gt;"Some Dude", :composer=&gt; 'First Dude', :duration=&gt;"2"},
   {:name=&gt;"Chick on the Side", :artist=&gt;"Another Dude"}]
  </code></pre>
  
  <p><code>a.uniq</code> won't work here because the duration is different or might not even exist. I have a unique key set up in the database that does not allow duplicate entries by the same name, artist and composer so I sometimes get errors when people have duplicate entries for these 3 keys. </p>
  
  <p><strong>Is there a way to run <code>uniq</code> that would check for those 3 keys?</strong> I tried a block like this:</p>
  
  <pre><code> new_tracks.uniq do |a_track|
     a_track[:name]
     a_track[:artist]
     a_track[:composer]
   end
  </code></pre>
  
  <p>But that ignores anything where the key is not present (any entry without a composer does not meet the above criteria for example).</p>
  
  <p>I could always use just the <code>:name</code> key but that would mean I'm getting rid of potentially valid tracks in compilations that have the same title but different artist or composer. </p>
  
  <p>This is with Ruby 2.0.</p>