From: Kristof Bastiaensen Date: 2004-04-09T18:44:21+09:00 Subject: Re: new method(?) collect_by On Fri, 09 Apr 2004 05:03:18 +0200, George Ogata wrote: > You might be interested in enumerator.rb in the std lib: > > irb(main):001:0> require 'enumerator' => true irb(main):002:0> 'a > string'.enum_for(:each_byte).map{|x| x} => [97, 32, 115, 116, 114, 105, > 110, 103] irb(main):003:0> 'a string'.enum_for(:each_byte).max => 116 > irb(main):004:0> 'a string'.enum_for(:each_byte).inject{|x,y| x+y} => > 792 > > etc. Hi, yes that does exactly what I wanted. I knew it should exist, but couldn't find it. I am still using ruby 1.6, so it must be part of 1.8. Thanks, Kristof