The order of evaluation in a Golang statement

Source: Internet
Author: User
This is a created article in which the information may have evolved or changed.

In Go specs, there are three points in this statement:

1. The evaluation Order (evaluation order) of the initialization expression (initialization expressions) in the variable declaration (variable declaration) is dependent by the initialization (initialization dependencies), but the evaluation of the operands inside the initialization expression needs to be in the order of 2: from left to right;
2. In a non-variable initialization statement, when the operands in an expression, an assignment statement, or a return statement are evaluated, the functions (function) calls, method calls, and communication operations contained in the operands (primarily for channel) are syntactically The order is evaluated from left to right.
3, the assignment statement evaluation is divided into two stages, the first stage is the index expressions on the left side of the equal sign, the pointer indirections and the expression to the right of the equals sign in the order of evaluation of the operands in 2 from left to right, and the second stage in left-to-right order of the variable assignment.

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.