title: How do I use Array#dig and Hash#dig introduced in Ruby 2.3?
body: <p>Ruby 2.3 introduces a new method on <code>Array</code> and <code>Hash</code> called <code>dig</code>. The examples I've seen in blog posts about the new release are contrived and convoluted:</p>
  
  <pre><code># Hash#dig
  user = {
    user: {
      address: {
        street1: '123 Main street'
      }
    }
  }
  
  user.dig(:user, :address, :street1) # =&gt; '123 Main street'
  
  # Array#dig
  results = [[[1, 2, 3]]]
  results.dig(0, 0, 0) # =&gt; 1
  </code></pre>
  
  <p>I'm not using triple-nested flat arrays. What's a realistic example of how this would be useful?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>It turns out these methods solve one of the most commonly-asked Ruby questions. The questions below have something like 20 duplicates, all of which are solved by using <code>dig</code>:</p>
  
  <p><a href="https://stackoverflow.com/questions/4371716/how-to-avoid-nomethoderror-for-missing-elements-in-nested-hashes-without-repeat">How to avoid NoMethodError for missing elements in nested hashes, without repeated nil checks?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/1820451/ruby-style-how-to-check-whether-a-nested-hash-element-exists">Ruby Style: How to check whether a nested hash element exists</a></p>