Created
October 23, 2018 06:06
-
-
Save jreisinger/0ec74b066b6b04622762a8fbb198c7a2 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" | |
| ) | |
| type SummableSlice []int | |
| func (s SummableSlice) sum() int { | |
| sum := 0 | |
| for _, n := range s { | |
| sum += n | |
| } | |
| return sum | |
| } | |
| func main() { | |
| s := SummableSlice{1, 2, 3} | |
| fmt.Println(s.sum()) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment