title: Don't pass block when calling super
body: <p>How can I set a block to nil for the <code>super</code> call?</p>
  
  <pre><code>class A
    def foo
      if block_given?
        result = yield 
        # do stuff with the yield result
      end
      # some more code
    end
  end
  
  class B &lt; A
    def foo
      block_result = yield
      # process block results and store it
      # ...
      super
    end
  end
  
  B.new.foo { puts "block called" }
  # =&gt; block called
  # =&gt; block called
  </code></pre>
  
  <p>I don't want to yield the block twice. Is it somehow possible that <code>block_given?</code> in class <code>A</code>  returns false?</p>
  
  <p>Background is that I don't own the <code>A</code> class and I can't change it's <code>foo</code> method but I want to avoid calling my block twice. I also don't want to pass a dummy / empty block to super, because the behaviour of <code>A</code>'s <code>foo</code> method changes when a block is given.</p>