From: Joel VanderWerf Date: 2005-05-05T06:01:16+09:00 Subject: Re: mapping an array to a hash? Logan Capaldo wrote: > On 5/3/05, Joel VanderWerf wrote: > > >>class Array >> def hashmap >> h={} >> each {|x| h[x] = yield x} >> h >> end >>end >> >>[1,2,3].hashmap {|x| x*10} >># => {1=>10, 2=>20, 3=>30} >> >> > > > Wouldn't it make more sense to put #hashmap in module Enumerable? > Just a thought. Of course. It would also probably make sense to choose a better name. #map_to_hash, maybe?.