From: David Alan Black Date: 2000-11-28T07:23:46+09:00 Subject: [ruby-talk:6593] Re: best way to interleaf arrays? On Mon, 27 Nov 2000, Dave Thomas wrote: > On the Hash front, I'm starting to think it would be useful to have > > Hash.from_array(ary, value) > > which was equivalent to > > def Hash.from_array(ary, value = 1) > h = {} > if block_given? > ary.each {|k| h[k] = yield(k,value) } > else > ary.each {|k| h[k] = value } > end > h > end What about a to_h method for arrays? I mention this mainly for the sake of symmetry with other to_* methods. Then again, such a method may violate some principle of design: it does seem slightly wrong for Array to "know" how to generate a hash (whereas not strange for Hash to know how to create itself from an array). David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav