Added noop case

Ivan Vazquez 2017-03-30 14:20:45 -07:00
parent 6a3f6ccf06
commit 77e5dbb474

@ -197,4 +197,27 @@ func do(v interface{}) string {
do(21) == "42"
do("bitrab") == "rabbit"
do(3.142) == "unknown"
```
```
## Noop case
Sometimes it useful to have cases that require no action. This can look confusing, because it can appear that both the noop case and the subsequent case have the same action, but isn't so.
```go
func pluralEnding(n int) string {
ending := ""
switch n {
case 1:
default:
ending = "s"
}
return ending
}
fmt.Sprintf("foo%s\n", pluralEnding(1)) == "foo"
fmt.Sprintf("bar%s\n", pluralEnding(2)) == "bars"
```