Ruby Language

Comments

Single & Multiple line comments

Comments are programmer-readable annotations that are ignored at runtime. Their purpose is to make source code easier to understand.

Single line comments

The # character is used to add single line comments.

#!/usr/bin/ruby -w
# This is a single line comment.
puts "Hello World!"

When executed, the above program will output Hello World!

Multiline comments

Multiple-line comments can be added by using =begin and =end syntax (also known as the comment block markers) as follows:

#!/usr/bin/ruby -w
=begin
This is a multiline comment.
Write as many line as you want. 
=end
puts "Hello World!"

When executed, the above program will output Hello World!


This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow