|
We now have the code written for syntax checking and execution to get the desired result as the output of the code.
We will now check the syntax of the code and then the errors if any in the code.
To run a syntax check on our file, we need to write the below written statement:
$ ruby -cw sample1.rb
Here -c flag means to check the file for any syntax error and -w flag turns on the indication for the warning.
Now considering that we the interpreter didn’t notice any syntax error in our code we get the message as :
Syntax OK
on our screen, which states that the program is ready for the execution.
Here, the Ruby interpreter can check programs for syntax errors without running the programs. It scans the entire file by going through it and intimates the programmer if there is any syntax error which needs attention.
|