我似乎无法修复此错误:
NoMethodError:nil 的未定义方法“+”:NilClass
这是我正在加载的文件中的代码:
def test_person_name
fred = Person.new("Fred", "Jones", 43)
result = fred.name
assert_equals("Fred Jones", result, "Name was wrong.")
end
这是另一个代码:
class Person
def initialize(first_name, last_name, age)
@first_name = first_name
@last_name = last_name
@age = age
end
def name()
@first_name + " " + @last_name
end
def age()
@age
end
def ==(other)
other.name == name
end
end