Last active
September 27, 2018 18:55
-
-
Save comtom/54d62b66bc7d3cc5372a0a104ab28e44 to your computer and use it in GitHub Desktop.
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
| func sum(nums ...int) { | |
| fmt.Print(nums, " ") | |
| total := 0 | |
| for _, num := range nums { | |
| total += num | |
| } | |
| fmt.Println(total) | |
| } | |
| func main() { | |
| sum(1, 2) | |
| sum(1, 2, 3) | |
| nums := []int{1, 2, 3, 4} | |
| sum(nums...) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment