From: Zengqh Mansion Date: 2011-02-20T19:51:22+09:00 Subject: About the "def method=(param)",why compiled error? very simple program: class Song def initialize(duration) @duration = duration end def duration=(new_duration) @duration = new_duration end end song = Song.new(260) print song.duration the compiler outputs: D:/我的文档/Ruby/attr_writer.rb:12:in `
': undefined method `duration' for # (NoMethodError)。 appreciate for your help. -- Posted via http://www.ruby-forum.com/.