chrisjroos@gmail.com
10/19/2006 11:26:00 AM
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?
>
class MySuperClass; end
Class.new(MySuperClass) #=> create anonymous class that inherits from
MySuperClass.