How annotations are used in Ruby

Source: Internet
Author: User

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:

?

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

When the above program executes, the following results are produced:

?

1 Hello, ruby!.

Multiple-line comments for Ruby

You can comment out multiple lines using the =begin and =end syntax 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. But =begin and =end should come in the the-only. =end

When the above program executes, the following results are produced:

?

1 Hello, ruby!.

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:

?

1 2 @counter # keeps track times page has been hit @siteCounter # keeps track the Times all pages have been hit
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.