作成したい新しいクラスの名前を入力するようにユーザーに依頼します。私のコードは次のとおりです。
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
これもうまくいきません。