From: "David A. Black" Date: 2004-09-11T21:19:45+09:00 Subject: Re: Singleton method on object via define_method? Hi -- On Sat, 11 Sep 2004, 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?? If my Kernel#singleton_class RCR gets accepted (or if you write an ad hoc version of it), you'll at least be able to shorten it to: box.singleton_class.class_eval { ... } David -- David A. Black dblack@wobblini.net