Syntax
if initialization; condition {
}
Example
a := 10
if a == 10
{
fmt.Println("Value of a is
10")
}
Above
statements can be written like below.
if a :=
10; a == 10 {
fmt.Println("Value of a is
10")
}
HelloWorld.go
package main import "fmt" func main() { if a := 10; a == 10 { fmt.Println("Value of a is 10") }else { fmt.Println("Value of a is 11") } }
Output
Value of a
is 10
No comments:
Post a Comment