Created
May 27, 2014 08:02
-
-
Save shockalotti/36790db099fc318fce25 to your computer and use it in GitHub Desktop.
Go Golang - variadic function (with unknown number of arguments)
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 add(args ...int) int { | |
total :=0 | |
for _, v := range args { | |
total += v | |
} | |
return total | |
} | |
func main() { | |
fmt.Println(add(1,2,3)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment