ch3: fix code path

This commit is contained in:
chai2010
2016-01-20 23:25:13 +08:00
parent 7fe7a309be
commit ca0f87fad9
5 changed files with 9 additions and 31 deletions

View File

@@ -36,9 +36,8 @@ const (
隨着iota的遞增每個常量對應表達式1 << iota是連續的2的冪分别對應一個bit位置使用這些常量可以用於測試設置或清除對應的bit位的值
<u><i>gopl.io/ch3/netflag</i></u>
```Go
gopl.io/ch3/netflag
func IsUp(v Flags) bool { return v&FlagUp == FlagUp }
func TurnDown(v *Flags) { *v &^= FlagUp }
func SetBroadcast(v *Flags) { *v |= FlagBroadcast }
@@ -74,5 +73,3 @@ const (
不過iota常量生成規則也有其局限性。例如它併不能用於産生1000的冪KB、MB等因爲Go語言併沒有計算冪的運算符。
**練習 3.13** 編寫KB、MB的常量聲明然後擴展到YB。