From: ahoward Date: 2002-11-27T03:47:24+09:00 Subject: Re: each_with_index & collect_with_index? On Wed, 27 Nov 2002 dblack@candle.superlink.net wrote: [snip] D> It could get unclean in a hurry, though :-) D> D> class Thing < Array D> def meth(other) D> a = collect { |e| do_something_with(e) } D> b = collect_with_index(self,other)... # ugh D> ... D> end D> end [snip] i'm unclear as to what you mean : a = collect { |e| do_something_with(e) } this would be Array#collect, what does it have to do with the following line? b = collect_with_index(self,other)... i don't really understand to point of the example. and why 'ugh'? you have to have, at minimum, one method name and a name for each Enumerable in the argument list : how could it get any more succinct than that? if you have a better suggestion i can incorporate it and post it... on second thought i would like to retract earlier statements about those methods belonging in Kernel (what was i thinking ) and say those methods should go in Enumerable as module methods so the above would need be b = Enumerable.collect_with_index(self,other)... i've updated http://eli.fsl.noaa.gov/lib/ruby/site_ruby/1.6/enumerable.rb to reflect this. i think we may be at cross-purposes : what i'm suggesting are methods which operate over n Enumerable items in synchronicity - not instance methods to be inherited by classes mixing in Enumerable... was this clear? -a -- ==================================== | Ara Howard | NOAA Forecast Systems Laboratory | Information and Technology Services | Data Systems Group | R/FST 325 Broadway | Boulder, CO 80305-3328 | Email: ahoward@fsl.noaa.gov | Phone: 303-497-7238 | Fax: 303-497-7259 ====================================