title: How do I detect duplicate values within an array in Ruby?
body: <p>Say I have an array that looks like:</p>
  
  <pre><code>a = [cat, dog, cat, mouse, rat, dog, cat]
  </code></pre>
  
  <p>How do I cycle through that, and do something with duplicates - e.g. say delete them?</p>
  
  <p>In other words, if I did <code>a.each do |i|</code>, how do I evaluate a[0], against a[1], a[2], a[3]...and then when I find the one I want, say a[2] in this case has the first duplicate, I then push it to a stack or remove it or something.</p>
  
  <p>I know how to evaluate keys, versus values...but how do I evaluate values against each other within the same array?</p>
  
  <p>Thanks.</p>