Ruby Japanese manual translation 2

Source: Internet
Author: User

Program:

1: formula (that is, code line, haha)
2: Termination of the program

Programs are composed of sub-statements. Use semicolons (;) or line breaks (;) to distinguish between formulas and formulas.
In the middle of a row, separate them with semicolons. If they are separated in two rows, they do not need semicolons ). However, if the backslash (\) is used
One row continues with the previous row.

Example: Print "Hello world! \ N "(as always Hello World)
  1. Statement:
Example: true (1 + 2) * 3foo () If test then OK else ng end

The ruby formula is filled with variables and constants, various types of direct quantities, operations and substitution, such as if and while control structures.
Call methods, define classes and methods. Operators can be grouped by parentheses. The null substatement () is returned as nil.
Ruby statements can return values or do not return values.

The following statements do not return values:

While, until, while modifier, until Modifier

In addition, for methods, you can specify parameters or do not specify parameters.

Do not specify the sub-statement of the method parameter:

And, or, not if/unless/rescue Modifier

If no parameter is specified, you can use it in parentheses to group it like a normal expression.

2. Termination of the program

The Ruby interpreter stops reading the following symbols.
End of File
^ D (Control Character D) and ^ Z (Control Character Z)
Only the rows with _ end _ (if there is blank above, it will not be recognized, that is, an error occurs)

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.