Skip to content

Instantly share code, notes, and snippets.

@jreisinger
Created October 23, 2018 06:06
Show Gist options
  • Select an option

  • Save jreisinger/0ec74b066b6b04622762a8fbb198c7a2 to your computer and use it in GitHub Desktop.

Select an option

Save jreisinger/0ec74b066b6b04622762a8fbb198c7a2 to your computer and use it in GitHub Desktop.
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