title: combining two if conditions in one line
body: <p>I have a hash value:</p>
  
  <pre><code>request.session["flash"]["alert"]
  </code></pre>
  
  <p>I need to write an <code>if</code> condition for the above hash value like:</p>
  
  <pre><code>if request.session["flash"]
    if request.session["flash"]["alert"]
      #Do something
    end
  end
  </code></pre>
  
  <p>I would like to combine both <code>if</code> condition in one line like:</p>
  
  <pre><code>if request.session["flash"] &amp;&amp; request.session["flash"]["alert"]
    #do something
  end 
  </code></pre>
  
  <p>But this would throw a nil class error if <code>flash</code> is not there. How can I write two <code>if</code> conditions in one line, where if one condition passes it executes the other?</p>