I want to say thanks for everyone's responses. It took me a couple days
to go through them all and it helped me learn quite a bit.
* Robert's example with Enumerable was neat.
* Hal's use of symbols was cool and interesting.
* Ross's use of a simple string probably made the most sense for my
situation
In the end I decided that simplest was best and subclassed String for
each respondent: adding save, load, and changed? methods.
respondents.each do |respondent|
respondent.open
respondent[0..2] = 213
respondent.close
end
I've been struggling with object oriented programming for years with
Perl, and only now (with Ruby) do I feel like I'm starting to really
"get" it. It's all about creating an interface that makes sense to use
from a larger perspective. The object hides the gritty details.
Like with the above interface, I could load the respondent from memory,
from database, or disk and it wouldn't matter at all to the rest of the
program. That's sexy and makes my life easier.
Thanks again for everyone's help. I certainly became a better
programmer after playing with your examples.
Regards,
Mike Judge
--
Posted via http://www.ruby-forum.com/.