From: Ralf Mueller Date: 2009-08-24T19:04:57+09:00 Subject: Re: Stupid OpenStruct question --------------040907050704030606070700 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Robert Klemme wrote: > 2009/8/24 Ralf Mueller : > >> Robert Klemme wrote: >> >>> On 24.08.2009 06:02, Terry Smith wrote: >>> > > >>>>> Great - ok how do I WORK with these once I have them? >>>>> >>> Just a remark: if your processing is mainly bases on keys this way then a >>> Hash might the better data structure. IMHO an OpenStruct is best used when >>> you are lazy or do not know all the fields that you are going to use >>> beforehand. I find this especially useful during development, you can stuff >>> in more and more fields but maybe later change it to a regular class (or >>> Struct generated class). >>> > > >> I had a similar experience with using OpenStruct and Hashes and in the end, >> I derived my class from OpenStruct (build up a hash within the contructor >> and create object with 'super()'). >> > > I am not sure what you are trying to convey here. Why would I want to > create a class that inherits OpenStruct and build up a Hash > internally? The io-part of my app reads text files and creates objects from them (csv-like files with named columns). I use many of the Hash methods internaly, but the OpenStruct gives me all the accessors for the api and the possibility to create objects from other input types (eg. hashs or arrays, coming from a database access) with the same constructor. Your Struct-example seems more elegant to me. I guess, I should start a rewrite... Thanks, ralf --------------040907050704030606070700--