title: How to sum numbers in nested arrays in Ruby?
body: <p>I got this array:</p>
  
  <pre><code>array = [["R.M", 20], ["R.U-CS", 3], ["R.M-TIC", 3], ["R.J.CONF", 20]]
  </code></pre>
  
  <p>I want to <code>sum</code> the numeric values, so I have converted this into a single array by using <code>flatten</code>:</p>
  
  <pre><code>array = array.flatten
  #=&gt; ["R.M", 20, "R.U-CS", 3, "R.M-TIC", 3, "R.J.CONF", 20]
  </code></pre>
  
  <p>then:</p>
  
  <pre><code>a = []
  array.each do |r|
    a &lt;&lt; r if r.class == Fixnum
  end
  a 
  </code></pre>
  
  <p>This works, but I am searching for a simpler solution, maybe converting the array into an "only <code>numeric</code>" array first:</p>
  
  <pre><code>[20, 3, 3, 20]
  </code></pre>