title: Equivalent of .try() for a hash to avoid "undefined method" errors on nil?
body: <p>In Rails we can do the following in case a value doesn't exist to avoid an error:</p>
  
  <pre><code>@myvar = @comment.try(:body)
  </code></pre>
  
  <p>What is the equivalent when I'm digging deep into a hash and don't want to get an error?</p>
  
  <pre><code>@myvar = session[:comments][@comment.id]["temp_value"] 
  # [:comments] may or may not exist here
  </code></pre>
  
  <p>In the above case, <code>session[:comments]try[@comment.id]</code> doesn't work. What would?</p>