On 10/12/05, Sean O'Halpin <sean.ohalpin / gmail.com> wrote:
> This isn't quite what you asked for but it achieves the same effect:
>
> class Foo
>  def red(&p)
>   self.class.send(:define_method, :z, &p)
>  end
>
>  def blue(y)
>  puts y
>  z(y)
>  end
>
>  def green
>   puts "Yeah!"
>  end
> end
>
> x = Foo.new
>
> x.red do |y|
>  green
>  puts y
> end
>
> x.blue 5
> __END__
> 5
> Yeah!
> 5
>
> Regards,
>
> Sean
>

Scratch that - it defines a method on the class not the object so all
Foos would get the z method. Hmm.. I'll have to think about this
(should have done that before I posted ;)

Sean