title: Forwarding an iterator
body: <p>I have class (highly simplified for the sake of this discussion)</p>
  
  <pre><code>class MyClass
    def initialize
      @myrecs = %w(a b c d)
    end
    def each_rec
      @myrecs.each {|r| yield(r)}
    end
  end
  </code></pre>
  
  <p>and use it as</p>
  
  <pre><code>x = MyClass.new
  x.each_rec { |r| .... }
  </code></pre>
  
  <p>Since my method <code>each_rec</code> basically does just a <code>myrecs.each</code>, I wanted to define somehow that <code>each_rec</code> just forwards to <code>each</code>. I can achieve the desired effect by explicitly passing the block, i.e.</p>
  
  <pre><code>def each_rec(&amp;block)
    @myrecs.each(&amp;block)
  end
  </code></pre>
  
  <p>but I wonder wether it is also possible to achieve my goal without having the block as explicit parameter. I tried the following approaches without success:</p>
  
  <p>(1) Exploit the fact that <code>each</code> returns an Enumerator when called without a block:</p>
  
  <pre><code>  def each_rec
      @myrecs.each
    end
  </code></pre>
  
  <p>(2) Create an Enumerator:</p>
  
  <pre><code>   def each_rec
       @myrecs.enum_for(:each)
     end
  </code></pre>
  
  <p>In both cases, I did not get an error, but the block passed to <code>each_rec</code> was simply not entered.</p>