From: Marc Rene Arns Date: 2002-05-30T06:43:32+09:00 Subject: Re: object-name = content of a variable (migration from perl) I'm not sure if you got me right. The dynamically changing array-names was in respect to the abilities of PERL. The idea to do it in ruby was to create new objects of the same class in a loop, but the number of objects is generated automatically changing (value of a variable) and also a part of the object-names should reflect a running number, so that later I would be able to read in a loop (who is changing the number) object by object with their parameters, s.th. Like this p = 'name' i = 0 while (weather == fine) o_name = p+i o_name = test.new('give me', 'some parameters') i += 1 end what should create the objects name0, name1, etc. all belonging to the same class test. >>>>>>>>>>>>>>>>>> Urspr�ngliche Nachricht <<<<<<<<<<<<<<<<<< Am 29.05.02, 21:05:23, schrieb Alan Chen zum Thema Re: object-name = content of a variable (migration from perl): > On Thu, May 30, 2002 at 04:23:21AM +0900, Marc Rene Arns wrote: > > I'm new to programing and ruby as well and I want to ?convert? a > > PERL-Script, I've recently written into ruby. In the Perl-script, I > > produced in a while-loop every time a different array who's name came > > from a variable counting every time higher, something like that > > > > $i = 1; > > while ($i < 10){ > > @{$i} = (?several?, ?changing?, ?variables?); > > $i = $i+1; > > } > > > > so that I got a set of arrays @1, @2, and so on > > > > Now I want to do the same thing in ruby, but I found no way to do it.. > I think another poster mentioned one way to dynamically create your > array names in ruby. As an alternative, is there any reason the data > has to be stored in @1, @2, etc? Could you just as easily store the > data in a hash: > @data = Hash.new # {} works too > 10.times { |i| > @data[i] = [ ?several?, ?changing?, ?variables? ] > } > -- > Alan Chen > Digikata LLC > http://digikata.com