You can do it in the In programming You can nest Nested use The result of the above code execution is: if or else if statement to embed one or more if or else if statement. 2.20.1. Grammar #
Go language the syntax of the if...else statement is as follows:If Boolean expression 1 {
/* Execute when Boolean expression 1 is true */
If Boolean expression 2 {
/* Execute when Boolean expression 2 is true */
}
}
else if...else statements within the if statement in the same way 2.20.2. Example #
if Statement:Example #
package main
import "fmt"
func main() {
/* Define local variables */
var a int = 100
var b int = 200
/* Judging conditions */
if a == 100 {
/* Execute if the conditional statement is true */
if b == 200 {
/* Execute if the conditional statement is true */
fmt.Printf("The value of a is 100, and the value of b is 200\\n" );
}
}
fmt.Printf("The value of a is : %d\\n", a );
fmt.Printf("The value of b is: %d\\n", b );
}
The value of a is 100, and the value of b is 200
The value of a is: 100
The value of b is: 200