From: gao bo Date: 2007-05-19T11:07:17+09:00 Subject: Why "NoMethodError" occurs ------=_Part_62874_31458344.1179540436799 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline hi, everyone today i typed the code below in my IDE class Song attr_reader :name, :artist, :duration attr_writer :duration def initialize(name, artist, duration) @name = name @artist = artist @duration = duration end def durationInMinutes @duration/60.0 end def durationInMinutes=(value) @duration = (value * 60).to_i end end class Song def to_s "song: #{@name}--#{@artist} (#{@duration})" end end aSong = Song.new("hello", "zhutou","332") puts aSong.to_s puts aSong.durationInMinutes And i tried to run it, but the error occured: song: hello--zhutou (332) song.rb:12:in `durationInMinutes': undefined method `/' for "332":String (NoMethodError) from song.rb:29 Why? Thanks! ------=_Part_62874_31458344.1179540436799--