Friday, 3 May 2019

Go language: if statement


Syntax
if condition {

}

If the condition evaluates to true, then the block of statements followed by if block are executed.

HelloWorld.go
package main

import "fmt"

func main() {

 a := 10

 if a == 10 {
  fmt.Println("Value of a is 10")
 }

 if a == 11 {
  fmt.Println("Value of a is 11")
 }
}

Output
Value of a is 10



Previous                                                 Next                                                 Home

No comments:

Post a Comment