From: "David A. Black" Date: 2009-02-07T21:56:47+09:00 Subject: Re: Array#to_h Hi -- On Sat, 7 Feb 2009, Tom Link wrote: >> Yes, if that's the semantics you want. If you're inclined toward >> thinking it should use the array indices as hash keys and the array >> values as hash values, then that implementation wouldn't work. > > With that constructor at hand, it wouldn't be too difficult to get > that behaviour though: > > a = [[1,2],[3,4]] >> Hash[(0..(a.size - 1)).zip(a)] > => {0=>[1, 2], 1=>[3, 4]} None of this is hard to do without Array#to_h, but there's still the question of what Array#to_h would do if it existed. David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Coming in 2009: The Well-Grounded Rubyist (http://manning.com/black2) http://www.wishsight.com => Independent, social wishlist management!