title: Ruby add / sum variable
body: <p>I'm looking for an explanation as to why this works:</p>
  
  <pre><code>def somesum
    x = 0
    (1..10).each do |number|
      x += number
    end
    puts x
  end
  </code></pre>
  
  <p>whereas this does not work (undefined method '+' for nil class):</p>
  
  <pre><code>def somesum
    (1..10).each do |number|
      x += number
    end
    puts x
  end
  </code></pre>
  
  <p>neither does this:</p>
  
  <pre><code>def somesum
    (1..10).each do |number, x|
      x += number
    end
    puts x
  end
  </code></pre>