class Song
def initialize(name,artist,duration)
@name=name
@artist=artist
@duration=duration
end
def to_s
"Song: #{@name}--#{@artist} (#{@duration})"
end
end
class KarokeSong < Song
def intialize(name,artist,duration,lyrics)
super(name,artist,duration)
@lyrics=lyrics
end
end
aSong=KarokeSong.new("Umerilla ila ila ila a","Rihanna",260,"my lyrics")
puts aSong.to_so
$我将此文件命名为jukebox.rb我正在使用ruby版本2.0.0 p451,当我尝试运行此示例时,ruby解释器发出以下错误
参数数量错误(4个中的4个)(参数错误)
来自jukebox.rb:20:在'new'
中来自jukebox.rb:20:在'main'
答案 0 :(得分:2)
KarokeSong的initialize
方法拼写错误。