This article mainly introduces the usage of annotation in Ruby, the usage of annotation is one of the most basic knowledge points in each programming language, and the friend who needs it can refer to
Code that is annotated in a Ruby line is ignored at run time. Single-line comment # characters begin, they are from # to end of line:
|
#!/usr/bin/ruby-w # is a single line comment. Puts "Hello, ruby!" |
When the above program executes, the following results are produced:
Multiple-line comments for Ruby
You can comment out multiple lines using the =begin and =end syntax as follows:
|
#!/usr/bin/ruby-w puts "Hello, ruby!" =begin This is a multiline comment and con Spwan as many lines as. But =begin and =end should come in the the-only. =end |
When the above program executes, the following results are produced:
Make sure that the comment that follows is a code that retains enough distance to make it easy to differentiate. If there is more than one end note in a block, they are aligned. For example:
|
@counter # keeps track times page has been hit @siteCounter # keeps track the Times all pages have been hit |