Clarify the type of variadic params with a comment

This commit is contained in:
Eli Bendersky
2022-06-24 12:43:35 -07:00
parent c662818d23
commit f197dfc6e1
3 changed files with 21 additions and 4 deletions

View File

@@ -12,6 +12,9 @@ import "fmt"
func sum(nums ...int) {
fmt.Print(nums, " ")
total := 0
// Within the function, the type of `nums` is
// equivalent to `[]int`. We can call `len(nums)`,
// iterate over it with `range`, etc.
for _, num := range nums {
total += num
}

View File

@@ -1,2 +1,2 @@
dd2e819d49c1110c7eb7dc198b62e0994e0ba93e
7_-i75JEsmM
561184169a1b4c3d4970d496b282cc81016583d6
glNdE8aKPNq