Created
May 7, 2018 14:39
-
-
Save picatz/eb060078369755c38f4ef7530a4e52c7 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
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