I have a scenario where I will be storing thousands of objects in an
array. Each one will have, say, two attributes, name and age. Some of
them may have other attributes in addition.

Note: I don't need to have any methods, inheritance or any other
'class-ish' behavior. Just the data.

Here are three representations. Which one will be faster? Which one will
be smaller?

class O
  def initialize (n, a)
    @name = n
    @age = a
end

O.new("jack", 11)

OR

{:name => "Jack", :age => 11}

OR

Struct.new("O", :name, :age)
O.new("Jack", 11)
-- 
Posted via http://www.ruby-forum.com/.