From: Christian Date: 2007-10-22T08:50:40+09:00 Subject: Re: How to use a hash inside a Struct? ------=_Part_13500_11395634.1193010637390 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline It might be easier to use OpenStruct. require 'ostruct' house = OpenStruct.new house.room = {:room_id => 'id', :room_name => 'name'} house.attr1 = 'some value' etc... On 10/22/07, Jayson Williams wrote: > > I am creating a class that creates elements of a house. For the part > that creates new rooms, I wanted to link the room name with a room id. > There may be multiple rooms with the same name, but only one room with > the unique combination of name and id. I was thinking to use a Hash > inside the structure definition of the room for the name and id. > > > On 10/21/07, Daniel N wrote: > > On 10/22/07, Jayson Williams wrote: > > > > > > Is there a way to use a hash inside a Structure. Something like: > > > > > > object = Struct.new(Hash.new(), :attr2, :attr3) > > > > > > I know this doesn't work, but do you get the idea of what I am trying > to > > > do? > > > > > > Jayson > > > > > > > > Nope. What are you trying to do? > > > > -Daniel > > > > -- "Every child has many wishes. Some include a wallet, two chicks and a cigar, but that's another story." ------=_Part_13500_11395634.1193010637390--