title: Making map! enumerator do what I want
body: <p>Having an array</p>
  
  <pre><code>a = 1, 2, 3, 4
  </code></pre>
  
  <p>And an enumerator:</p>
  
  <pre><code>e = a.map!
  </code></pre>
  
  <p>Then, by calling <code>e.next</code> repeatedly, array a gets nicely destroyed:</p>
  
  <pre><code>e.next #=&gt; 1
  a #=&gt; [1, 2, 3, 4]
  e.next #=&gt; 2
  a #=&gt; [nil, 2, 3, 4]
  e.next #=&gt; 3
  a #=&gt; [nil, nil, 3, 4]
  </code></pre>
  
  <p>That's so hilarious! But when I try</p>
  
  <pre><code>e.next { |x| 2 * x } # =&gt; 4
  </code></pre>
  
  <p>I get</p>
  
  <pre><code>a #=&gt; [nil, nil, nil, 4]
  </code></pre>
  
  <p>instead of desired</p>
  
  <pre><code>a #=&gt; [nil, nil, nil, 8]
  </code></pre>
  
  <p>What am I misunderstanding? How to make <code>a.map!</code> do what I want with the elements?</p>
  
  <p>My problem is, that I do not fully understand enumerators. With the previous code in place, for example, enumerator <code>e</code> constitutes a backdoor to <code>a</code>:</p>
  
  <pre><code>e.each { 42 }
  a #=&gt; [42, 42, 42, 42]
  </code></pre>
  
  <p>I would like to know, how to do this gradually, with values other than nil. (I can gradually fill it with nils using <code>e.rewind</code> and <code>e.next</code> several times, as I shown before.</p>