Skip to content

Instantly share code, notes, and snippets.

@lamarmarshall
Created October 25, 2017 04:22
Show Gist options
  • Select an option

  • Save lamarmarshall/76348c9d1e10f9c99f5b309e9b7803e1 to your computer and use it in GitHub Desktop.

Select an option

Save lamarmarshall/76348c9d1e10f9c99f5b309e9b7803e1 to your computer and use it in GitHub Desktop.
go variadic functions, go functions with multiple arguments, go array into funcs
package main
import "fmt"
func Addall(nums ...int) int {
res := 0
for _, n := range nums {
res += n
}
return res
}
func main() {
result := Addall(3, 1, 89, 45, 75)
fmt.Printf("%v \n", result)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment