Single-line and multiple-line comments
suggest changeComments 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!
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents