From: gabriele renzi Date: 2007-09-29T23:55:05+09:00 Subject: Re: Is there a combination of a struct and an array? I wanna iterate over all created objects from a certain struct-class (I guess). On Sat, 29 Sep 2007 15:37:07 +0200, kazaam wrote: > but how to achieve this? any idea or suggestion? maybe: Person=Struct.new(:name,:hobby,:home) def read_data(io) io.gets.chomp.split('=')[1] end def read_person(io) name= read_data(io) hobby= read_data(io) job=io.gets home= read_data(io) Person.new(name,hobby,home) end people=[] people << read_person(DATA) while not DATA.eof? puts people or people={} name = nil DATA.each do |line| case line when /name=(.*)/ name=$1 people[name]= {'name'=>name} when /(hobby|home)=(.*)/ people[name][$1]=$2 end end p people HTH -- goto 10: http://www.goto10.it blog it: http://riffraff.blogsome.com blog en: http://www.riffraff.info