On 8/8/07, dblack / rubypal.com <dblack / rubypal.com> wrote: > Hi -- > > On Wed, 8 Aug 2007, Robert Dober wrote: > > > require 'labrador/enum' > > a.zip(a.map.succ).map.join.first(-1) map without a parameter creates a Proxy object that contains the enumeration and the method name :map. It's method_missing forwards everything to the enumeration via send and the method name, thus map.join becomes map{|x| x.send(:join)} it is not everybody's cup of tea, but I love it, obviously. Labrador, the LAZY programmers best friend ;) class EmptyProxy < EmptyObject def initialize object, message @enum = object @message = message end end class Dispatcher < EmptyProxy def method_missing mth, *args, &blk @enum.send(@message){|x| x.send(mth.to_sym,*args)} end # def method_missing mth, *args, &blk end # class Dispatcher < EmptyProxy Cheers Robert -- [...] as simple as possible, but no simpler. -- Attributed to Albert Einstein