Clarify the type of variadic params with a comment
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
dd2e819d49c1110c7eb7dc198b62e0994e0ba93e
|
||||
7_-i75JEsmM
|
||||
561184169a1b4c3d4970d496b282cc81016583d6
|
||||
glNdE8aKPNq
|
||||
|
||||
Reference in New Issue
Block a user