From: "Ara.T.Howard" Date: 2005-10-25T16:42:02+09:00 Subject: Re: Array#to_h On Tue, 25 Oct 2005, Robert Klemme wrote: > Daniel Sheppard wrote: >> Problem is - which [].to_h is intuitive. There's a to_h in nano: >> >> http://nano.rubyforge.org/doc/classes/Array.html#M000057 >> >> You can already do: >> >> a = [1, 2, 3, 4, 5] >> hash = a.inject({}) {|h,x| h[x] = x*2} > > Won't work. This at least has to be > > hash = a.inject({}) {|h,x| h[x] = x*2;h} i've been writing that this way lately, just because i looks better: hash = a.inject({}){|h,x| h.update x => x*2} creates an xtra hash - but less anoying that ;h -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | anything that contradicts experience and logic should be abandoned. | -- h.h. the 14th dalai lama ===============================================================================