From: "David A. Black" Date: 2009-09-16T04:46:59+09:00 Subject: Re: Array of Hashes in an array of hashes - Complicated! Hi -- On Wed, 16 Sep 2009, Aldric Giacomoni wrote: > +1 on object creation > > There's a Ruby tutorial somewhere on the interblag about creating a > mini-adventure game. It begins like this: > > def Thing > attr_accessor :name, :description > end > > And everything starts from there. > > def Weapon < Thing > end > > def Sword < Weapon > end > > etc etc. You probably don't need that much breaking down, but it seems > you do need to break it down some ;-) > The basic way to think about it is : if I can't explain it in three > sentences or less, I have to break it down. > > If you REALLY REALLY REALLY wanted to create some kind of iterating > name, you could always do things like > iterator = 0 > array = [] > while iterator < 30 > array << "a#{iterator}".to_sym > iterator += 1 > end > > But that's really dirty... array = (0...30).map {|i| :"a#{i}" } (Probably irrelevant to the thread but I couldn't resist :-) David -- David A. Black, Director Ruby Power and Light, LLC (http://www.rubypal.com) Ruby/Rails training, consulting, mentoring, code review Book: The Well-Grounded Rubyist (http://www.manning.com/black2)