这是我的第一个红宝石应用程序。而且我是堆栈溢出处女......当我运行以下程序时:
class NameApp
def intialize(name)
@names = []
end
def name_question
print "What is your name? "
answer = gets.chomp
@names += answer.to_s
puts "The number of characters in your name is " + names.length
end
def name_length
if @names.length > 25 then
print "Your name is longer than 25 characters."
else
print "Your name is too short."
end
end
end
name_app = NameApp.new("Test1")
name_app.class # => NameApp
name_app.name_question
name_app.name_length
我得到这个简单的错误消息结果:
name.rb:26:in `initialize': wrong number of arguments(1 for 0) (ArgumentError)
from nameapp.rb:26:in `new'
from nameapp.rb:26:in `<main>'
你能帮我解决问题吗?