On Sat, Sep 11, 2004 at 06:48:07PM +0900, Hal Fulton wrote:
> OK, I have this variable called box.
> 
> I want to define a singleton method xy on it. No problem.
> 
> However, I need a closure. So I need to use define_method
> rather than def.
> 
> This is how I did it:
> 
>   class << box; self; end.class_eval { define_method(:xy) {[x,y]} }
> 
> Surely there is an easier way??

I don't think so :-) I asked this a long time ago; Guy Decoux provided the
same answer at RubyTalk:68053 and I wrote it up at
http://www.rubygarden.org/ruby/ruby?SingletonTutorial

Regards,

Brian.