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