"David Alan Black" <dblack / candle.superlink.net> wrote in message
news:Pine.LNX.4.30.0110202111100.3271-100000 / candle.superlink.net...
> Hello --
>
> On Sun, 21 Oct 2001, Daniel Berger wrote:
>
> > Hi all,
> >
> > What's the easiest (i.e. a one liner) for creating a hash based on an
array?
> > I just wanted to convert an array to a hash, using the even numbered
indices
> > as the key and the odd numbered indices as the value for that key.
> >
> > array = ['one', 1, 'two', 2, 'three', 3]
>
> hash = Hash[*array]
>
> (The * turns the array into a bare list of its elements.)
>
> I've always advocated an Array#to_h method, though that was before I got
the
> hang of the above :-)  I still think there might be use for some methods
that
> make array<->hash conversions more transparent.

I'm all for a "to_h" method. :)

Thanks for the info!

Dan