17. Switch
Switch Statement
switch condition {
case x:
code to execute
case y:
code to execute
default:
code to execute
}No Fall-through
i := 2
switch i {
case 1:
fmt.Println("i is one")
case 2:
fmt.Println("i is two")
case 3:
fmt.Println("i is three")
case 4:
fmt.Println("i is four")
}Switch without expression
Last updated