Comments

A comment hides a line, part of a line, or several lines from the Ruby interpreter. You can use the hash character (#) at the beginning of a line:

# I am a comment. Just ignore me.

Or, a comment may be on the same line after a statement or expression:

name = "Floydene" # ain't that a name to beat all

You can make a comment run over several lines, like this:

# This is a comment.
# This is a comment, too.
# This is a comment, too.
# I said that already.

Here is another form. This block comment conceals several lines from the interpreter with =begin/=end:

=begin
This is a comment.
This is a comment, too.
This is a comment, too.
I said that already.
=end

A block can comment out one line or as many lines as you want.

Get Ruby Pocket Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.