Easier to understand fallthrough example

Atila Romero 2018-08-02 16:21:07 -03:00
parent 01d386c23f
commit 63e14fa99a

@ -102,6 +102,29 @@ default:
To fall through to a subsequent case, use the ` fallthrough ` keyword:
```go
v := 42
switch v {
case 100:
fmt.Println(100)
fallthrough
case 42:
fmt.Println(42)
fallthrough
case 1:
fmt.Println(1)
fallthrough
default:
fmt.Println("default")
}
// Output:
// 42
// 1
// default
```
Another example:
```go
// Unpack 4 bytes into uint32 to repack into base 85 5-byte.
var v uint32