Statements that are not executed by the compiler and interpreter are called Comments. During coding proper use of comments makes maintenance easier and finding bugs easily.
In Ruby, there are two types of comments:
- Single – line comments.
- Multi – line comments.
Here, we are going to explain both types of comment with their syntax and example:
Ruby Single-Line Comments –
It is represented by # sign. It is used to denote single line comment in Ruby. Its the most easiest typed comments. When we need only one line of a comment in Ruby then we can use the characters ‘#’ preceding the comment.
Single line comment above
Ruby Multi-Line Comments –
If our comment is extending in more than one line than we can use a multiline comment.In Ruby, Multi- Line Comment started by using =begin and ended by using =end syntax.
=begin continues continues . . . Commnent ends =end
Multi line comments below
We can also execute single line comments by using the above syntax as shown below:
=begin Comment line 1 =end
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.