title: Check hash for nil values
body: <p>I'm trying to analyze tweets off of Twitter and one of the things I would like to include is the location. Unfortunately, some of the values are nil and I keep getting the error</p>
  
  <pre><code>undefined method `[]' for nil:NilClass (NoMethodError)
  </code></pre>
  
  <p>I would like to just run a check to see if the value is nil or not but I can't get anything to work.</p>
  
  <p>The input would look like this if it is nil</p>
  
  <pre><code>tweet = {"metadata"=&gt; {"geo"=&gt;nil}}
  </code></pre>
  
  <p>and this if it has value</p>
  
  <pre><code>tweet = {"metadata"=&gt; {"geo"=&gt;{"coordinates"=&gt;[0,1]}}
  </code></pre>
  
  <p>This is what I've tried</p>
  
  <pre><code>if "#{tweet['metadata']['geo']}".nil? == true
    puts("nil")
  else
    puts("#{tweet['metadata']['geo']['coordinates']}"
  end
  </code></pre>
  
  <p>What I've noticed is that it just checks to see if geo is empty because it outputs "nil" if I change the if statement to equal false. I'm not sure how else to check</p>