Interpreting the usage of annotations in Ruby and interpreting ruby annotations

Source: Internet
Author: User

Interpreting the usage of annotations in Ruby and interpreting ruby annotations

The Code Annotated In the Ruby line is ignored at runtime. Single line comment # starts with the characters. They start from # To the end of the line as follows:

#! /Usr/bin/ruby-w # This is a single line comment. puts "Hello, Ruby! "

When the above program is executed, the following results are generated:

Hello, Ruby!

Ruby multiline comments

You can comment out multiple rows using the = begin and = end syntax as follows:

#! /Usr/bin/ruby-wputs "Hello, Ruby! "= BeginThis is a multiline comment and con spwan as your lines as youlike. But = begin and = end shocould come in the first line only. = end

When the above program is executed, the following results are generated:

Hello, Ruby!

Make sure that the subsequent comments are codes that keep enough distance to make it easy to differentiate. If there is more than one ending end comment in a block, they are aligned. For example:

@ Counter # keeps track times page has been hit @ siteCounter # keeps track of 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.