Hi --

On Mon, 25 Nov 2002, Damon wrote:

> Ross Shaw <rshaw1961 / yahoo.com.au> wrote in message news:<rshaw1961->  Robert Cowham <rc / vaccaperna.co.uk> wrote:
> >
> > h = {}
> > File.foreach("fred.ini") do |line|
> >   key, value = line.chomp.split("=")
> >   h[key] = value
> > end
> >
> >
> > Ross
>
>
> Thank you!  This is clear and still concise.  The other responses seem
> to gravitate towards Perl-like one-liners. But this defeats the
> purpose of writing in Ruby---to avoid Perl obfuscations.  The above is
> much more readable and also much more idiomatic than many of the
> others.  This should go into athe Ruby Cookbook (if it were still up).

Uh oh, I think I might be an obfuscation suspect :-) But please -- I
must insist that my obfuscations be denounced as Ruby obfuscations,
not Perl ones :-) Perl is a red herring here; Perl style isn't
necessarily a point of reference at all, one way or the other, when
one decides to use Ruby or to do specific things in Ruby.

I personally put reading a config file in a kind of utilitarian,
"let's just do this and move on" category -- and those types of things
I do like to trim down to near-minimum code.  It's my impression that
that can actually add to the overall clarity of a program file.  But a
lot of this is in the eye of the beholder.  Ross's code certainly
looks fine to me.

Idiomatic-ness is of course hard to measure.  But I definitely like
the Hash[*array] idiom.  It's a technique that would be more familiar
and would probably seem more idiomatic if it were used more often, and
would be used more often if it seemed more familiar....  so someone's
got to break the cycle :-)


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav