我要求用户输入我要创建的新类的名称。我的代码是:
puts "enter the name for a new class that you want to create"
nameofclass = gets.chomp
nameofclass = Class.new
为什么这不起作用?
另外,我想要求用户输入我想添加到该类的方法的名称。我的代码是:
puts "enter the name for a new method that you want to add to that class"
nameofmethod = gets.chomp
nameofclass.class_eval do
def nameofmethod
p "whatever"
end
end
这也不起作用。