Robert Klemme wrote:
> This variant does not allow for easy adding of methods via Functor#+
> though.  But you can easily define a method add(method,&block) that adds a
> method and returns self for chaining:
> 
> class Functor
>   def add(method, &block)
>     class << self;self;end.class_eval do
>       define_method(method,&block)
>     end
>     self
>   end
> 
>   alias :initialize :add
> end
> 
> Functor.new(:x){puts "x"}.
>   add(:y){puts "y"}.
>   add(:z){puts "z"}.y

Mmm, not sure. I really like the ability to use the + method. Seems like there should be a way to use "define_method" and still support the "+" method. Anybody have time to give it a go?

--
John Long
http://wiseheartdesign.com