From: Trans Date: 2007-11-10T23:37:59+09:00 Subject: Re: equivalent injecting implementations? On Nov 10, 8:50 am, "Rick DeNatale" wrote: > On 11/9/07, Trans wrote: > > > > > Are these strictly equivalent? I get the feeling no, but I haven't > > been able to demonstrate it yet. > > > def injecting(s) > > inject(s) do |k, i| > > yield(k, i); k > > end > > end > > > def injecting(res, &block) > > ([res]*length).zip(to_a).each(&block) > > res > > end > > > Thanks, > > T. > > I can't see how in general they can be. > > In which class or module are you defining these? Since you are using > inject and each, I'm guessing that it's either Enumerable or some > subclass, > > But then depending on which subclass you don't have a length method so... > > Perhaps some more context would help. Oh sorry, I meant to put that. These are Enumerable methods. T.