variadic parameters code example
Example: variadic parameters
package main
import "fmt"
func sum(n ...int) (s int) {
for _, v := range n {
s += v
}
return
}
func main() {
fmt.Print(sum(1, 2, 3, 4))
}
package main
import "fmt"
func sum(n ...int) (s int) {
for _, v := range n {
s += v
}
return
}
func main() {
fmt.Print(sum(1, 2, 3, 4))
}