On Mon 12 Jul 2004 at 07:33:51 +0900, Sam Stephenson wrote:

> There's a few trivial but useful "extensions" to Ruby's standard
> library that I find myself using in most of my projects. I'll share a
> couple, and I'd really love to see what you're using, too.

I often find myself needing to instantiate a populated Hash, based on
the contents of two arrays, where the first contains what will become
the keys of the Hash and the second the values.

I use the following for this:

irb(main):001:0* foo = %w[ a b c ]
=> ["a", "b", "c"]
irb(main):002:0> bar = %w[ d e f ]
=> ["d", "e", "f"]
irb(main):003:0> baz = Hash[ *( foo.zip( bar ).flatten ) ]
=> {"a"=>"d", "b"=>"e", "c"=>"f"}

Nice, but I'd like it even more if ruby had a more direct and legible
way of achieving the same goal.

Ian
-- 
Ian Macdonald               | Obstacles are what you see when you take
System Administrator        | your eyes off your goal. 
ian / caliban.org             | 
http://www.caliban.org      | 
                            |