From: Dan Doel Date: 2004-04-09T11:01:39+09:00 Subject: Re: new method(?) collect_by Interesting. I don't think I've ever seen that before. If you find that useful, perhaps you'll find the following interesting: class Object def inject_by(init, method, *args, &blk) a = init send(method, *args) do |*o| a = yield a, o end a end def collect_by(method, *args, &blk) inject_by([], method, *args) do |a, o| a << if blk blk.call *o else o.size > 1 ? o : o[0] end end end end My #collect_by and yours does the same thing, plus I made the even more general #inject_by. :) I don't know where I'd ever use this, but who knows? Cheers. - Dan