2 ms·
When you say "switch <value>", it matches the "case" statements based on if the value after "case" is equal to <value>. So, if you say const P = 3.141
by supersillyus 15y ago
When you say "switch <value>", it matches the "case" statements based on if the value after "case" is equal to <value>. So, if you say
const P = 3.141
switch 3.141 {
case P:
fmt.Println("This prints")
}
When no value is specified after "switch", the value of "true" is implied, which is why you can do:
switch {
case a && b: ..
case something():
}