Interpreting the use of annotations in Ruby

Time:2022-5-25

 RubyHanlin AcademiciannotesThe code for is ignored at run time. The single line comment starts with the characters, and they are as follows from to the end of the line:

?
1
2
3
4
5
#!/usr/bin/ruby -w
 
# This is a single line comment.
 
puts "Hello, Ruby!"

When the above procedure is executed, the following results will be produced:

?
1
Hello, Ruby!

Multiline comments for ruby

You can comment out multiple lines and use the syntax of = begin and = end as follows:

?
1
2
3
4
5
6
7
8
#!/usr/bin/ruby -w
 
puts "Hello, Ruby!"
 
=begin
This is a multiline comment and con spwan as many lines as you
like. But =begin and =end should come in the first line only.
=end

When the above procedure is executed, the following results will be produced:

?
1
Hello, Ruby!

Make sure that the following comments are code that keeps enough distance to make it easy to distinguish. If more than one endnote exists in a block, they are aligned. For example:

?
1
2
@counter   # keeps track times page has been hit
@siteCounter # keeps track of times all pages have been hit