Syntax
switch {
case caseStatement1 :
statements
case caseStatement2 :
statements
…..
…..
default
:
statements
break
}
HelloWorld.go
package main import "fmt" func main() { a := 10 switch { case a > 10: fmt.Println("Value of a is > 10") case a <= 10: fmt.Println("Value of a is <= 10") } }
Output
Value of a
is <= 10
No comments:
Post a Comment