M
macaco
[Note: parts of this message were removed to make it a legal post.]
Hi.
I've been wondering if I can instantiate during execution, I have this
subclasses, but I don't know how to do it by their name as a string.
This is what I mean:
class superClass
...
end
class subClass1 < superClass
...
end
class subClass2 <superClass
...
end
class caller
type = ['subClass1','subClass2']
def create_class(var)
#instantiate class type[var]
newClass = type[var].new # ?????
end
end
I don't wanna do it with a case clause, cos I don't know when I'm going to
add more subclasses.
Any idea?
Hi.
I've been wondering if I can instantiate during execution, I have this
subclasses, but I don't know how to do it by their name as a string.
This is what I mean:
class superClass
...
end
class subClass1 < superClass
...
end
class subClass2 <superClass
...
end
class caller
type = ['subClass1','subClass2']
def create_class(var)
#instantiate class type[var]
newClass = type[var].new # ?????
end
end
I don't wanna do it with a case clause, cos I don't know when I'm going to
add more subclasses.
Any idea?