Switch
Switch
Note: that break does not exist, only one case is selected
func main() {
switch i := 1; i {
case 1:
println("its one")
case 2:
println("its two")
case 3:
println("its three")
default:
println("never seen a number like that before")
}
}Switch with no condition
func main() {
i := 3
switch {
case 1 == i:
println("its one")
case 2 == i:
println("its two")
case 3 == i:
println("its three")
default:
println("never seen a number like that before")
}
}