Single-line and multiple-line comments

suggest change

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

Single line comments

# starts a comment that runs to the end of the line.

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

When executed, the above program will output Hello World!

Multiline comments

A block from =begin to =end is a comment. Both markers must be at the beginning of the line. An indented =begin is not a comment marker.

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

When executed, the above program will output Hello World!

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents