title: Unpacking a Hash in ruby
body: <p>I wonder if there is any method which can unpack the hashes inside an array. For example</p>
  
  <pre><code>array = [{:code=&gt;"404"}, {:code=&gt;"302"}, {:code=&gt;"200"}]
  </code></pre>
  
  <p>After unpacking it should give </p>
  
  <pre><code>array = [code: "404", code: "302", code: "200"]
  </code></pre>
  
  <p>I have tried using flat_map as follows</p>
  
  <pre><code>array.flat_map { |h| h.values } &amp; array.flat_map { |h| h.keys }
  </code></pre>
  
  <p>But these are 2 separate arrays.</p>