Created
August 25, 2014 15:35
-
-
Save Imater/f7db8f1c2e0afa7a6324 to your computer and use it in GitHub Desktop.
varradic multiply arguments
This file contains 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 add(a ...int) int { | |
sum := 0 | |
for _, num := range a { | |
sum += num | |
} | |
return sum | |
} | |
func main() { | |
fmt.Println(add(2,3,4,5,6)) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment