From: Clemens Hintze Date: 2001-10-27T07:54:25+09:00 Subject: [ruby-talk:23565] Re: RCR #50 Simplifying the use of map by adding optional parameter Robert Feldt wrote: > > Hi, Hello Robert, > Below is a new RCR. If you feel anything about it please go to > > http://www.rubygarden.com/article.php?sid=127 to achieve similar goal, I did write a small utility that I called HOM. It looks like: module Enumerable class HOM def initialize(container, inplace) @every = container.method(inplace ? :collect! : :collect) end def method_missing(mid, *args) @every.call { |e| e.send(mid, *args) } end end def every; HOM.new(self, false) end def every!; HOM.new(self, true) end end You can use it like this: arr = [2, 3, 4, 5] p arr.every + 5 * 6 #-> [32, 33, 34, 35] p arr #-> [2, 3, 4, 5] arr.every!.succ p arr #-> [3, 4, 5, 6] Would this somewhat do what you want? But your proposal could also prove useful, though. Ciao, \cle