From: Elliot Temple Date: 2006-05-25T04:38:03+09:00 Subject: Re: define_method for a single instance? On May 24, 2006, at 11:18 AM, Jake McArthur wrote: > I'm trying to define a method for a specific instance of a class > rather than for every instance of the class. Basically, something > like this: > > class A > def add_wibble_method > # don't know what to do here > end > end > > foo = A.new > bar = A.new > foo.add_wibble_method > foo.wibble # should work > # bar.wibble should not work > > Any help would be appreciated. #the self is needed or bar gets wibble too. class A def add_wibble_method # don't know what to do here def self.wibble puts "wibble" end end end foo = A.new bar = A.new foo.add_wibble_method foo.wibble # should work bar.wibble rescue puts "error" -- Elliot Temple http://www.curi.us/blog/