 <p><code>if data["location"] &amp;&amp; data["location"]["country"] &amp;&amp; data["location"]["country"]["code]</code></p> <p>Ruby's <code>&amp;&amp;</code> operator is a short circut operator, so if the first operand is false, it will stop processing the rest of the condition. In addition. Any object that is not <code>nil</code>, is (for boolean purposes) <code>true</code>, so if the key exists, then it is <code>true</code></p>