title: Conditional blocks in Ruby
body: <p>Say I have function <code>with_foo</code> that takes a block, and wrap it around a piece of code, like</p>
  
  <pre><code>with_foo do
    puts "hello!"
  end
  </code></pre>
  
  <p>Now I would like to make the wrapping conditional, like</p>
  
  <pre><code>if do_with_foo?
    with_foo do
      puts "hello!"
    end
  else
    puts "hello!" # without foo
  end
  </code></pre>
  
  <p>Is there any way to write this shorter/more elegantly, meaning without having to repeat the code <code>puts "hello!"</code>?</p>