ch5: fix code path

This commit is contained in:
chai2010
2016-01-21 09:58:28 +08:00
parent 3666d2f0e8
commit 20a8cf71b9
7 changed files with 19 additions and 18 deletions

View File

@@ -4,8 +4,8 @@
在聲明可變參數函數時,需要在參數列表的最後一個參數類型之前加上省略符號“...”,這表示該函數會接收任意數量的該類型參數。
<u><i>gopl.io/ch5/sum</i></u>
```Go
gopl.io/ch5/sum
func sum(vals...int) int {
total := 0
for _, val := range vals {
@@ -14,6 +14,7 @@ func sum(vals...int) int {
return total
}
```
sum函數返迴任意個int型參數的和。在函數體中,vals被看作是類型爲[] int的切片。sum可以接收任意數量的int型參數
```Go