From: Nokan Emiro Date: 2012-12-03T19:45:34+09:00 Subject: Re: changing superclass --e89a8fb1ffc4d1151c04cff07268 Content-Type: text/plain; charset=UTF-8 Hi, What you do here is inserting a new Module into the ancestors chain. (The superclass of class Dog doesn't change, it's still Animal.) If you could do the same with a Stuff class (not module), that would be the right answer to my stupid question. u. On Mon, Dec 3, 2012 at 3:43 AM, 7stud -- wrote: > > class Animal > def greet > puts "Hi, I'm an Animal." > end > end > > class Dog < Animal > end > > Dog.new.greet > > module Stuff > def greet > puts 'Hello there.' > end > end > > new_superclass = Stuff > Dog.class_eval("include #{new_superclass}") > Dog.new.greet > --e89a8fb1ffc4d1151c04cff07268 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi,

What you do here is inserting a new Module into the = ancestors chain.
(The superclass of class Dog doesn't change,= it's still Animal.) =C2=A0If you
could do the same with a St= uff class (not module), that would be the
right answer to my stupid question.

u.
<= div>

On Mon, Dec 3, 2012 at 3:43 AM, 7stu= d -- <lists@ruby-forum.com> wrote:

class Animal
=C2=A0 def greet
=C2=A0 =C2=A0 puts "Hi, I'm an Animal."
=C2=A0 end
end

class Dog < Animal
end

Dog.new.greet
=C2=A0
module Stuff
=C2=A0 def greet
=C2=A0 =C2=A0 puts 'Hello there.'
=C2=A0 end
end

new_superclass =3D Stuff
Dog.class_eval("include #{new_superclass}")
Dog.new.greet
=C2=A0
--e89a8fb1ffc4d1151c04cff07268--