title: Hash/Array of objects in Ruby
body: <p>I'm pretty new to Ruby (I come from a C++ background) and I have an array/hash of objects by their name but I'm having no luck when trying to access their variables. This is my attempt:</p>
  
  <pre><code>class Foo
  attr_reader :num
  
  def initialize(num)
      @num = num
  end
  end
  
  foo_list = {}
  
  foo_list["one"] = Foo.new("124")
  foo_list["two"] = Foo.new("567")
  
  foo_list.each do |foo|
  p "#{foo.num}"              # ERROR: undefined method 'num'
  end
  </code></pre>
  
  <p>I'm pretty sure there is an easy way of doing what I need, maybe not even using 'each' but something else?</p>