As a prime example of a memorandum, I will write down the errors I encountered and the solutions.
syntax error = Since it is a syntax error, I get angry if something is wrong with the code I wrote. The code below is the result of outputting the file in the terminal.
main2.rb:81: syntax error, unexpected tIDENTIFIER, expecting ')' hp: params[:hp] main2.rb:82: syntax error, unexpected ':', expecting end offense: params[:offense] main2.rb:83: syntax error, unexpected ':', expecting end defense: params[:defense] main2.rb:84: syntax error, unexpected ')', expecting end )
super( name: params[:name] hp: params[:hp] offense: params[:offense] defense: params[:defense] )
main2.rb (modified code)
super( name: params[:name], hp: params[:hp], offense: params[:offense], defense: params[:defense] )
The cause was that each item in the super method was not separated by "," and all were treated as the same line, so I was angry.
** Note that the super method calls the method overridden by the method you are executing. Overriding is "overriding a method of a parent class with a child class". By using super in the initialize method, it is possible to execute the initialize method of the specified class. As a result, processing can be divided into "common parts" and "non-common parts". ** **
Traceback (most recent call last): main.rb:1:in `<main>': uninitialized constant <class name> (NameError)
I am angry that there is no such class name in the main.rb file. If you get an error that you want to call a separate file, Let's describe require as shown below so that another file can be called.
require './<class name>'
wrong number of arguments (given 1, expected 0) (ArgumentError)
Occurs in case of argument error. I'm passing one required value as (given 1, expected 0), but I'm angry that there is no recipient. Since there is a high possibility that you forgot to describe the argument in the first place, let's check the described method.
monster.rb:51:in `transform': undefined method `transform_message' for #<Monster:0x00007fea761c2b28> (NoMethodError)
Literally an error due to an undefined method.
It could simply be due to a typo, but it's also possible that some method forgot to close def ~ end. Pay attention to the position of the indent.
** The following will be added when an error is encountered and resolved. ** **