From: ahoward Date: 2003-02-28T07:01:47+09:00 Subject: Re: 'each' returning array On Fri, 28 Feb 2003 nobu.nokada@softhome.net wrote: > Hi, > > At Fri, 28 Feb 2003 06:01:31 +0900, > Wojciech Kaczmarek wrote: > > Is there a way to transparently accumulate expresions evaluated within > > a block into an array, without introducing an external variable? For > > example, I'd like to write something like this: > > > > "HAL".each_byte__returning_array {|x| (x+1).chr} .collect # more processing > > Enumerator in "rough". > > require "enumerator" > "HAL".enum_for(:each_byte).collect {|x| (x+1).chr} # => ["I", "B", "M"] how have i lived so long without knowing that! can you explain more? -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 ====================================