Olivier
3/17/2007 6:37:00 PM
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 :)
--
Olivier Renaud