title: Is there a shorthand equivalent for the double pipe operator which treats empty strings as falsy?
body: <p>In Ruby, it's common to use the double pipe operator to test if a variable is falsy and to apply some kind of default setting when variables are undefined. Here's a line of config I just came across in a codebase I'm doing some work on:</p>
  
  <pre><code>config.uh_product_name = ENV['UH_PRODUCT_NAME'] || 'Unicorn Hunt'
  </code></pre>
  
  <p>This is all well and good if <code>ENV["UH_PRODUCT_NAME"]</code> is <code>nil</code>. But in this case, because of the way the .env file is set by default, <code>ENV["UH_PRODUCT_NAME"]</code> is an empty string <code>""</code>, which is truthy. So the default is not applied.</p>
  
  <p>I could do this to handle this case:</p>
  
  <pre><code>config.uh_product_name = ENV['UH_PRODUCT_NAME'].present? ? 'Unicorn Hunt' : ENV['UH_PRODUCT_NAME'] 
  </code></pre>
  
  <p>But that's much less readable and ends up with a line of code that potentially stretches off screen.</p>
  
  <p>So, does anyone know of a shorthand operator along the lines of <code>||</code> that applies Rails's <code>.blank?</code> or treats empty strings as falsy? Something like this perhaps:</p>
  
  <pre><code>config.uh_product_name = ENV['UH_PRODUCT_NAME'] ?|| 'Unicorn Hunt'
  </code></pre>