Comments are lines of annotation or code within a program that are ignored at run time. Comments aid in guiding, providing context, and conveying the meaning of code.
Comments on a particular line are called single-line comments.
When a comment spans more than one line, it is a multi-line comment.
A single-line comment starts with the
# character and extends from the
# to the end of the line, as shown below.
# This is a single line comment. puts "This is a single line comment in Ruby"
You can comment multiple lines with
=end, as shown below.
puts "This is a multiline comment in Ruby" =begin This is a multiline comment and can span as many lines as you like. But =begin and =end should come in the first and last line only. =end
View all Courses