title: using inject to count elements in array
body: <p>I'm trying to count the occurrences of elements in an array and save it in a hash.  I'd like to use the inject function.  I have this code:</p>
  
  <pre><code>a = ["the","the","a", "it", "it", "it"]
  a.inject(Hash.new(0)) {|hash,word| hash[word] += 1}
  </code></pre>
  
  <p>I don't understand why I get the following error:</p>
  
  <pre><code>TypeError: can't convert String into Integer
      from (irb):47:in `[]'
      from (irb):47:in `block in irb_binding'
      from (irb):47:in `each'
      from (irb):47:in `inject'
  </code></pre>
  
  <p>Also, I don't know how to fix it.</p>