From: Elliott Hird Date: 2008-03-02T06:40:56+09:00 Subject: Re: Using a class to extend a singleton? On 01/03/2008, Trans wrote: > Given: > > class X > def yo=x; @yo=x; end > end > > class Y > def yo!; puts @yo; end > end > > x = X.new > > Is there any way to extend x with Y's functionality (without going > back and changing the given code)? Eg. > > >> x.yo="Hello World" > >> x.yo! > Hello World > > > T. class << x; Y.instance_methods.each {|m| define_method m, Y.method(:m)}; end kind of. brings in Object onwards, though, but that's easy to fix. -ehird