title: How to count duplicate elements in a Ruby array
body: <p>I have a sorted array:</p>
  
  <pre><code>[
    'FATAL &lt;error title="Request timed out."&gt;',
    'FATAL &lt;error title="Request timed out."&gt;',
    'FATAL &lt;error title="There is insufficient system memory to run this query."&gt;'
  ]
  </code></pre>
  
  <p>I would like to get something like this but it does not have to be a hash:</p>
  
  <pre><code>[
    {:error =&gt; 'FATAL &lt;error title="Request timed out."&gt;', :count =&gt; 2},
    {:error =&gt; 'FATAL &lt;error title="There is insufficient system memory to run this query."&gt;', :count =&gt; 1}
  ]
  </code></pre>