Ruby Japanese manual translation 1

Source: Internet
Author: User

Ruby Syntax:

1: Variable
2: Comment
3: embedded document
4: Reserved Words

Ruby currently uses the ASCII character set. It can recognize uppercase and lowercase letters. In addition to the variable and part of the direct amount, you can
Add spaces and comments anywhere, including spaces, tabs, vertical tabs, backspace, carriage return, line breaks, and page breaks. When
When the code continues to be written with a line feed, except for spaces, other statements are interpreted as separate statements. (Note: When the code is too long to be written
Only spaces can be added in the middle; otherwise, an error will occur)

<1> variables:

Example: foobarruby_is_simple

Ruby variable names can start and end with letters or underscores. There is no limit on the length of the variable name.

<2> note:

Example: # This is a comment line

Following the script language's habits, strings and numbers are directly counted, '? # ', From the beginning to the end of the line is considered as a comment
(Note: Comments in Perl are also used #)

<3> embedded document:

Example: = beginthe everything between a line beginning with '= begin' andthat with '= end' will be skipped by the interpreter. = end

(Note: embedded documents in Perl are also expressed in this way)
You can embed a document in the source code of Ruby. The start part of the document starts with = begin until = end.
In this form, the Ruby interpreter cannot limit the annotation content. It is best to use the annotation in the form of RD (Ruby document format.

<4> reserved words:

The following are reserved words:

BEGIN    class    ensure   nil      self     whenEND      def      false    not      super    whilealias    defined? for      or       then     yieldand      do       if       redo     truebegin    else     in       rescue   undefbreak    elsif    module   retry    unlesscase     end      next     return   until

Reserved Words cannot be used in class names or variable names. However, if the prefix $, @, and @ is added, they are not considered reserved words. In addition, after def or
After the terminator of a method call, it is clear that these reserved words can be used as the method name.

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.