From: James Gray Date: 2008-01-25T01:10:55+09:00 Subject: Re: Change a data structure On Jan 24, 2008, at 10:02 AM, 7stud -- wrote: > Michael Schmarck wrote: >> yermej wrote: >> >>> I'll offer up an inject version (mostly for novelty's sake): >>> timing_given.each {|k, v| timing_given[k] = v.inject(Hash.new {|h, >>> k| >>> h[k] = []}) {|acc, h| h.each {|k, v| acc[k] << v}; acc}} >> >> Geez - did you use to code perl code? Because Perl code tends to >> be as unreadable and compact as yours :) >> >> It works good, but I guess I've got some reading to do, to actually >> understand why it's working ;-> >> > > Don't bother. inject() is such an inefficient function it should > never > be used in ruby code. Ouch. That's a pretty bold claim. Is inject() too inefficient for use on a ten element Array? How about three? Perhaps "never" was the wrong word. James Edward Gray II