fork(145) download
  1. package main
  2. import "fmt"
  3.  
  4. func my_func( args ...int) int {
  5. sum := 0
  6. for _,v := range args {
  7. sum = sum + v
  8. }
  9.  
  10. return sum;
  11. }
  12.  
  13. func main() {
  14. arr := []int{2,4}
  15. sum := my_func(arr...)
  16. fmt.Println("Sum is ", sum)
  17. }
  18.  
Success #stdin #stdout 0s 420544KB
stdin
Standard input is empty
stdout
Sum is  6