On Tue, Jul 13, 2004 at 03:11:41PM +0900, Ian Macdonald wrote:
> 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"}

Trying to be too succinct can get you into trouble:

irb(main):001:0> a = [1, 2, 3]
=> [1, 2, 3]
irb(main):002:0> b = [[1], [2, 3], [4, 5]]
=> [[1], [2, 3], 3]
irb(main):003:0> Hash[ *( a.zip( b ).flatten ) ]
=> {1=>1, 2=>2, 3=>3, 4=>5}

Paul