From: "David A. Black" Date: 2005-10-25T19:13:14+09:00 Subject: Re: RCR: Array#to_h Hi -- On Tue, 25 Oct 2005, Trans wrote: > I think the proposal is over specialized. Why should the array elements > neccessarily become keys? > > Nobu, I agree except 1) key,value in Enumerable? 2) other clearly > polymorphic solution: > > module Enumerable > def to_h > hash = {} > each_with_index {|value,index| hash[i] = value} > hash > end > end > > Hence hash key <-> array index. And it is by definition "Enumerable". But then what's the point? :-) This raises the old question of why hashes have both keys and numerical indices. I've always maintained that they shouldn't. David -- David A. Black dblack@wobblini.net