Hi all:
Now I have problem about dynamiclly inheriting form a class.
For example:
···
--------
class_name='MyClass'
klass = Object.const_set(class_name, Class.new)
klass.class_eval do
...
end
--------
now i get a class named 'MyClass',then i want the MyClass inherit
from another
class 'AnotherClass',how can I do it?
Class.new(MySuperClass) #=> create anonymous class that inherits from
MySuperClass.
···
On 10/19/06, Hang Liu <liuhang1113@gmail.com> wrote:
Hi all:
Now I have problem about dynamiclly inheriting form a class.
For example:
--------
class_name='MyClass'
klass = Object.const_set(class_name, Class.new)
klass.class_eval do
...
end
--------
now i get a class named 'MyClass',then i want the MyClass inherit
from another
class 'AnotherClass',how can I do it?
Hi all:
Now I have problem about dynamiclly inheriting form a class.
For example:
--------
class_name='MyClass'
klass = Object.const_set(class_name, Class.new)
klass.class_eval do
...
end
--------
now i get a class named 'MyClass',then i want the MyClass inherit
from another
class 'AnotherClass',how can I do it?
------------------------------------------------------------------------
Creates a new anonymous (unnamed) class with the given superclass
(or Object if no parameter is given). You can give a class a name
by assigning the class object to a constant.