Skip to content

Instantly share code, notes, and snippets.

@theophoric
Created April 17, 2014 17:20
Show Gist options
  • Save theophoric/10999267 to your computer and use it in GitHub Desktop.
Save theophoric/10999267 to your computer and use it in GitHub Desktop.
custom slices
package main
import "fmt"
type foo int
type foos []foo
func (f foos) first() foo {
if len(f) == 0 {
return 0
}
return f[0]
}
func main() {
f := foos([]foo{1,2,3,4})
fmt.Print(f.first())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment