Olivier Renaud wrote:
> Le samedi 17 mars 2007 18:50, Corey Konrad a écrit :
>> I am trying to figure out how inheritance works using the super method.
>> With the sample code below i get the error that i dont have enough
>> arguments for the constructor i dont understand why i am getting that
>> error.
>>[...]
> 
> Hi Corey,
> 
> I have read the questions you posted the last few days, and I would like 
> to
> give you a general counsel. It looks like you don't take care of the 
> output
> when an exception is raised. Though, the informations displayed when an 
> error
> occurs are very useful, and if you had paid attention to it, you would 
> have
> found your error immediatly.
> 
> For your particular problem, you can see this output :
> 
> /tmp/animal.rb:13:in `initialize': wrong number of arguments (1 for 2)
> (ArgumentError)
>         from /tmp/animal.rb:13:in `initialize'
>         from /tmp/animal.rb:21:in `new'
>         from /tmp/animal.rb:21
> 
> If you don't already know, the first line means that at line 13 (line 13 
> is :
> super(color)) a method was called with 1 argument instead of 2. This is
> sufficient to start tracking down the error. The other lines represents 
> the
> call stack, ie the "path" which was followed to reach the exception.
> 
> And if there is an exception you don't understand, or that doesn't help 
> you,
> then join it with your code in your next message.
> 
> Happy learning :)

Alright thanks for the information. I knew what the error message meant 
to some degree i knew it had to do with the number of args in the 
constructor and i knew what line it was on but i still didnt understand 
why it was happening because i didnt understand how to use the super 
method correctly, i looked it up doing a ri super and there was no info 
that shed light on the issue either so i asked on here. The error 
message didnt help me out at all i mean if it spit out "Hey corey you 
need to do this super(color, age) instead of super(color) super(age)" 
then i would have had no problems understanding that.

-- 
Posted via http://www.ruby-forum.com/.