From: Todd Burch Date: 2007-08-15T06:39:27+09:00 Subject: Re: Class Instantiation jantzeno wrote: > I have a few questions about class instantiation. > > Say I have a class: > > class Person > attr_accessor :name, :age > end > > And an array: > > names = ["john", "jane"] > > Is it possible to instantiate a class using a string from the array so > I get something equal to: > > john = Person.new > jane = Person.new > > > v/r, You can, but it might be better to do something like this if you have lots of names in your names array: people = Array.new ; names.each_with_index {|n,i| people[i] = Person.new ; people[i].name = n ; } Todd -- Posted via http://www.ruby-forum.com/.