title: Ruby check if block is nil
body: <p>I call a method with a block;</p>
  
  <pre><code>method do
    "Hello"
  end
  </code></pre>
  
  <p>and the method is defined as;</p>
  
  <pre><code>def method
    yield
  end
  </code></pre>
  
  <p>and when defining <em>method</em>; i want to check if given block is empty (nil) or not, because the variable in the method may end up like this;</p>
  
  <pre><code>method do
    ""
  end
  </code></pre>
  
  <p>So in definition, i want to check if the <strong>yield</strong> block is nil or not. Like;</p>
  
  <pre><code>def method
    if yield ? yield : "Empty block? Seriously?"
  end
  </code></pre>
  
  <p>I know the above does not work. Bu it is what i want to achieve.</p>
  
  <p>Also keep in mind that <strong>block_given?</strong> will always be "true" since the block is given even if it is <em>nil</em> or <em>empty string</em>.</p>
  
  <p><strong>UPDATE</strong>: As most of the comments/answers state that the question is unclear; here is the problem simplified by @ndn:</p>
  
  <blockquote>
    <p>I want to check if the result of executing a block is "empty"(nil or "") without
    invoking it first.</p>
  </blockquote>