title: Ruby: Most concise way to use an ENV variable if it exists, otherwise use default value
body: <p>In Ruby, I am trying to write a line that uses a variable if it has been set, otherwise default to some value:</p>
  
  <pre><code>myvar = # assign it to ENV['MY_VAR'], otherwise assign it to 'foobar'
  </code></pre>
  
  <p>I could write this code like this:</p>
  
  <pre><code>if ENV['MY_VAR'].is_set? #whatever the function is to check if has been set
    myvar = ENV['MY_VAR']
  else
    myvar = 'foobar'
  end
  </code></pre>
  
  <p>But this is rather verbose, and I'm trying to write it in the most concise way possible. How can I do this?</p>