title: HOW-TO Create an Array of Hashes in Ruby
body: <p>New to ruby and I'm trying to create an array of hashes (or do I have it backwards?)</p>
  
  <pre><code>def collection
    hash = { "firstname" =&gt; "Mark", "lastname" =&gt; "Martin", "age" =&gt; "24", "gender" =&gt; "M" }
    array = []
    array.push(hash)
    @collection = array[0][:firstname]
  end
  </code></pre>
  
  <p>@collection does not show the firstname for the object in position 0... What am I doing wrong?</p>
  
  <p>Thanks in advance!</p>