Go_04:go language Base Conditional statement

Source: Internet
Author: User

1. Judgment statement If

1. Conditional expressions without parentheses (this is what other languages need to be aware of)

2. Support an initialization expression (can be in parallel, i.e.: A, B, c: = 1, 2, 3)

3. The opening brace must be on the same line as the conditional statement or else

4. Support single-line mode

5. The variable in the initialization statement is the block level, while the external variable with the same name is hidden

The sample code for the IF statement is as follows:

Package Mainimport"FMT"Func Main () {a:=true    ifA, B, c: =1,2,3; A + B + C >6{fmt. Println ("Greater than 6")    } Else{ fmt. Println ("less than or equal to 6") FMT. Println (A)} fmt. Println (a)}

Run the print results as follows:

Less than or equal to 61true

If the judgment statement is relatively simple, as long as the relevant grammatical structure and the relevant basic knowledge mentioned in the previous section, the application of the IF statement will have no problem.

2. Circular statement for

In continuous update

Go_04:go language Base Conditional statement

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.