Go Language Introduction (iii)

Source: Internet
Author: User

Conditional statements

The conditional statement structure of the Go language is as follows:

The go language's conditional statements are similar to other languages. Briefly listed below:

1, if statement, Boolean expression does not require parentheses

If  boolean expression  {/* Executes when the Boolean expression is true */}
     

2. If...else statement

The If  boolean expression  {/* Executes when the Boolean expression is true */}Else{/* whenthe Boolean expression is False */}

3. If statement nesting

If Boolean expression   1{/* executes when Boolean expression 1 is true */if Boolean expression 2 {/* isexecuted when Boolean expression 2 is true */}
                        
                         }
                        

4. Switch statement

Slightly different from other languages, var1 can be any type, val1 and val2 must be the same type as var1. A case statement does not require a break, only matches and executes one of the items, and ends the switch statement

Switch{case     val1:... case val2:... default:... }

Go Language Introduction (iii)

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.