Skip to content

Instantly share code, notes, and snippets.

@picatz
Created May 7, 2018 14:39
Show Gist options
  • Save picatz/eb060078369755c38f4ef7530a4e52c7 to your computer and use it in GitHub Desktop.
Save picatz/eb060078369755c38f4ef7530a4e52c7 to your computer and use it in GitHub Desktop.
package main
import "fmt"
var exampleNumbers = []int{1, 2, 3, 4, 5}
func sumOfNumbers(numbers []int) (result int) {
for _, number := range numbers {
result += number
}
return
}
func main() {
sum := sumOfNumbers(exampleNumbers)
fmt.Println(sum)
}
// Output:
// 15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment