title: Ruby: Use Nested Arrays to Compile Values with Similar First Item
body: <p>I have a Ruby nested array like this:</p>
  <pre><code>arr = [[&quot;Red&quot;, 2], [&quot;Red&quot;, 1], [&quot;Yellow&quot;, 0], [&quot;Yellow&quot;, 2], [&quot;Blue&quot;, 1]]
  </code></pre>
  <p>And I'm trying to find a method that adds up the number (which is the second item in each mini-array) for similar items, yielding a nested array like this:</p>
  <pre><code>[[&quot;Red&quot;, 3], [&quot;Yellow&quot;, 2], [&quot;Blue&quot;, 1]]
  </code></pre>
  <p>I've tried for loops, and if statements, but I can't figure out exactly how to do it.</p>
  <p>With a non-nested array you could just use <code>if</code> and <code>.includes?</code>, but I'm not sure how to work that with a nested array.</p>
  <p>Any Ruby wizards able to steer me in the right direction here?</p>