title: In Ruby, what's the advantage of #each_pair over #each when iterating through a hash?
body: <p>Let's say I want to access the values of a hash like this:</p>
  <pre><code>munsters = {
    &quot;Herman&quot; =&gt; { &quot;age&quot; =&gt; 32, &quot;gender&quot; =&gt; &quot;male&quot; },
    &quot;Lily&quot; =&gt; { &quot;age&quot; =&gt; 30, &quot;gender&quot; =&gt; &quot;female&quot; },
    &quot;Grandpa&quot; =&gt; { &quot;age&quot; =&gt; 402, &quot;gender&quot; =&gt; &quot;male&quot; },
    &quot;Eddie&quot; =&gt; { &quot;age&quot; =&gt; 10, &quot;gender&quot; =&gt; &quot;male&quot; },
    &quot;Marilyn&quot; =&gt; { &quot;age&quot; =&gt; 23, &quot;gender&quot; =&gt; &quot;female&quot;}
  }
  </code></pre>
  <p>I could use <code>#each</code> with two parameters:</p>
  <pre><code>munsters.each do |key, value| 
      puts &quot;#{name} is a #{value[&quot;age&quot;]}-year-old #{value[&quot;gender&quot;]}.&quot;
  end
  </code></pre>
  <p>Or I could use <code>#each_pair</code> with two parameters:</p>
  <pre><code>munsters.each_pair do |key, value| 
      puts &quot;#{name} is a #{value[&quot;age&quot;]}-year-old #{value[&quot;gender&quot;]}.&quot;
  end
  </code></pre>
  <p>Perhaps the difference between the two is not borne out in this simple example, but can someone help me to understand the advantage of using <code>#each_pair</code> over <code>#each</code> ?</p>