From: Robert Klemme Date: 2009-02-02T02:44:55+09:00 Subject: Re: Array#to_h On 31.01.2009 21:03, 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", ....] > > ? Or even raise an Exception because Array#to_h expects a nested structure as is returned from various Hash methods (e.g. #select, #to_a - note, this is about to change in new versions of Ruby). Kind regards robert