Created
October 25, 2017 04:22
-
-
Save lamarmarshall/76348c9d1e10f9c99f5b309e9b7803e1 to your computer and use it in GitHub Desktop.
go variadic functions, go functions with multiple arguments, go array into funcs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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