August 2019
Beginner to intermediate
798 pages
17h 2m
English
The main reason for presenting the switch statement in this chapter is because a switch case can use regular expressions. Firstly, however, take a look at this simple switch block:
switch asString {
case "1":
fmt.Println("One!")
case "0":
fmt.Println("Zero!")
default:
fmt.Println("Do not care!")
}
The preceding switch block can differentiate between the "1" string, the "0" string, and everything else (default).
However, a switch statement can ...
Read now
Unlock full access