请告诉我我在这里做错了什么。我希望能够通过方法将稍后在代码中添加的任何字符串大写titles
。
class Book
attr_accessor :book_title
def initialize
@book_title = String.new
end
def titles
book_title.capitalize
end
end
@book = Book.new
puts @book.titles = "steve jobs"
因为当我执行它时,我得到undefined method `titles=' for #<Book:0x007fbd25813d98 @book_title=""> (NoMethodError)