title: What are the block variables capturing?
body: <p>One tutorial has this block of code:</p>
  
  <pre><code>h1 = ["a" =&gt; 111, "b" =&gt; 222]
  h2 = ["b" =&gt; 333, "c" =&gt; 444]
  h1.merge(h2) {|key, old, new| new}
  # =&gt; ["a" =&gt; 111, "b" =&gt; 333, "c" =&gt; 444]
  h1.merge(h2) {|key, old, new| old}
  # =&gt; ["a" =&gt; 111, "b" =&gt; 222, "c" =&gt; 444]
  </code></pre>
  
  <p>We have a conflict with the merge. Two duplicate keys across our two arrays. <code>new</code> is capturing <code>h2</code>'s value for <code>"b"</code>, and outputting it forces it to take priority in the merge. Similarly, <code>old</code> is capturing <code>h1</code>'s value for <code>"b"</code>, and forces it to take priority.</p>
  
  <p>Why are we seemingly only grabbing the values for <code>"b"</code>? Shouldn't the variables be grabbing the whole array(s)? Are the block variables context-sensitive and change function when used with <code>.merge</code> as opposed to, say, <code>.times</code>? Or is it that they change function when we're dealing with arrays instead of simple numericals? Or is it that they see a merge conflict and are like "we got to capture the point of conflict"? I thought that maybe trying to see what was in <code>key</code> would help,</p>
  
  <pre><code>h1.merge(h2) {|key, old, new| key}
  # =&gt; ["a" =&gt; 111, "b" =&gt; "b", "c" =&gt; 444]
  </code></pre>
  
  <p>but it actually just made me more confused. Why is one variable capturing the key, whereas the others are capturing the two different values?</p>