From: Zach Dennis Date: 2005-05-29T13:33:52+09:00 Subject: Re: Thankyou caio Navya Amerineni wrote: > Hi caio, > > thanks for your valuble suggestion and it works > great.I have one another silly question > > this is the code > class Song > def initialize(name, artist, duration) > @name=name > @artist=artist > @duration=duration > end > def myclass_function > puts "this is my first class" > end > def to_s > puts "Song: #@name--#@artist (#@duration)" > end > end > class Karaokesong > def initialize(name, artist, duration, lyrics) > super(name, artist, duration) > @lyrics=lyrics > end > def to_s > puts "Song: #@name--#@artist (#@duration)" > end > end > > the following is the error > > "myfirstprojectfile:16:in `initialize': wrong number > of arguments (3 for 0) (ArgumentError)" > > the error is with super. > > can you explain why it is. Change the following line: class Karaokesong to: class Karaokesong < Song That will make Karaokesong a subclass of Song. When you call super it will call Song's initialize method which takes 3 arguments. When it doesn't subclass Song, Karaokesong by default will subclass from Object. Object itself doesn't take any arguments in it's constructor. HTH, Zach