more
This commit is contained in:
parent
ce6b86fccd
commit
9572a6b4f7
15
22-varargs.go
Normal file
15
22-varargs.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func add(nums ...int) int {
|
||||||
|
total := 0
|
||||||
|
for _, num := range nums {
|
||||||
|
total += num
|
||||||
|
}
|
||||||
|
return total
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
fmt.Println(add(1, 2, 3, 4))
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user