From: Eero Saynatkari Date: 2006-09-13T12:39:20+09:00 Subject: Re: Newbie Alert John Legate wrote: > 01 class Song > 02 def initialize(name, artist, duration) > 03 @name = name > 04 @artist = artist > 05 @duration = duration > 06 end > 07 def to_s > 08 puts "Song: #{@name}--#{@artist} (#{@duration})" Here is your problem. #puts prints out the String but it returns nil. > 09 end > 10 end > 11 > 12 aSong = Song.new("My Way", "Sinatra", 225) > 13 print "aSong.to_s ==> " > 14 aSong.to_s > 15 > 16 class KaraokeSong < Song > 17 def initialize(name, artist, duration, lyrics) > 18 super(name, artist, duration) > 19 @lyrics = lyrics > 20 end > 21 def to_s > 22 super + " [#{@lyrics}]" So here you have printed it out but have gotten a nil back, whence your error since nil does not respond to #+. > 23 end > 24 end > 25 > 26 kSong = KaraokeSong.new("My Way", "Sinatra", 225, "And now, the...") > 27 print "kSong.to_s ==> " > 28 kSong.to_s -- Posted via http://www.ruby-forum.com/.