An interpretation of the use of annotations in Ruby _ruby special topics

Source: Internet
Author: User

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:

Hello, ruby!.

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:

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:

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

Related Article

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.