title: rails nested hash with default values
body: <p>I'd like to create a new Hash with nested default values. I thought it should be like</p>
  
  <pre><code>h = Hash.new(count: 0, rating: 0)
  </code></pre>
  
  <p>So I can do stuff like</p>
  
  <pre><code>h['a'][:count] += 1
  h['a'][:rating] += 1
  </code></pre>
  
  <p>and so on. But when I try it in the console it looks like this:</p>
  
  <pre><code>2.3.1 :046 &gt; h = Hash.new(count: 0, rating: 0)
   =&gt; {} 
  2.3.1 :047 &gt; h["a"]
   =&gt; {:count=&gt;0, :rating=&gt;0} 
  2.3.1 :048 &gt; h["a"][:count]
   =&gt; 0 
  2.3.1 :049 &gt; h["a"][:count] += 1
   =&gt; 1 
  2.3.1 :050 &gt; h["b"][:count] += 1
   =&gt; 2
  2.3.1 :051 &gt; h
   =&gt; {}
  </code></pre>
  
  <p><strong>So my questions are:</strong></p>
  
  <ul>
  <li>Why is <code>h["b"][:count] += 1</code> returning 2 and not 1?</li>
  <li>why is h empty?</li>
  </ul>
  
  <p>Thanks in advance!</p>