title: Merging keys and values from hash in Ruby
body: <p>I have a hash with the number of occurrences of cities from a model and I want to merge <code>nil</code> or <code>blank</code> keys and values into one and rename the new single key</p>
  
  <p>for example</p>
  
  <pre><code>@raw_data = {nil =&gt; 2, "" =&gt; 2, "Berlin" =&gt; 1, "Paris" =&gt; 1}
  # to
  @corrected_data = {"undefined" =&gt; 4, "Berlin" =&gt; 1, "Paris" =&gt; 1}
  </code></pre>
  
  <p>I have looked into the merge method from the Rubydoc but it only merges if two keys are similar, but in this case <code>nil</code> and <code>""</code> are not the same.</p>
  
  <p>I could also create a new hash and add <code>if nil or blank</code> statements and add the values to a new <code>undefined</code> key, but it seems tedious. </p>