module A
class B
class Base
end
end
end
module A
class B
class C < A::B::Base
def hello_c
puts 'hello class C method hello_c'
end
end
end
end
module A
class B
class D < A::B::Base
def hello_d
puts 'hello class D method hello_d'
end
end
end
end
module A
class B
classs E < A::B::Base
def hello_e
puts 'hello class E method hello_e'
end
end
end
end
................
str = ['c','d','e'].sample
A::B.const_get(str.to_s.classify).new 这个是工作的
我想要实现 A::B.new(str) 来替代上面的方法,请问该怎么处理呢?@lgn21st @rei