title: Create hash from array and frequency
body: <p>I have an array <code>[1,2,4,5,4,7]</code> and I want to find the frequency of each number and store it in a hash. I have this code, but it returns <code>NoMethodError: undefined method '+' for nil:NilClass</code></p>
  
  <pre><code>def score( array )
    hash = {}
    array.each{|key| hash[key] += 1}
  end
  </code></pre>
  
  <p>Desired output is</p>
  
  <pre><code>{1 =&gt; 1, 2 =&gt; 1, 4 =&gt; 2, 5 =&gt; 1, 7 =&gt; 1 }
  </code></pre>