From: Julian Leviston Date: 2009-02-07T09:22:35+09:00 Subject: Re: Array#to_h It's fairly trivial, isn't it? >> class Array >> def to_h >> Hash[*self] >> end >> end => nil >> [1,2,3,4].to_h => {1=>2, 3=>4} >> On 01/02/2009, at 7:03 AM, David A. Black wrote: > Hi -- > > On Sun, 1 Feb 2009, Roger Pack wrote: > >> Not that I would find it useful at all, but is there is a Hash#to_a >> should there not be an Array#to_h? > > Not if it's not useful :-) It might be, though. It's been talked about > a lot over the years. As I recall, part of the problem is the question > of what it would mean; for example, given this: > > ["a","b","c","d"].to_h > > is it > > ["a" => "b", "c" => "d"] > > or > > [0 => "a", 1 => "b", ....] > > ? > > > 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! >