From: Wojciech Kaczmarek Date: 2003-10-10T01:24:39+09:00 Subject: Re: 'each' returning array On Fri, 28 Feb 2003 06:39:45 +0900, nobu.nokada@softhome.net 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 > Finally I've written a 5-lines long mixin, .. > Enumerator in "rough". > > require "enumerator" > "HAL".enum_for(:each_byte).collect {|x| (x+1).chr} # => ["I", "B", "M"] ...but this module is great, nice that it's going to be included in ruby distro. Thanks! -- This is not a healthy way of thinking. (Emacs Psychiatrist)