Skip to content

Instantly share code, notes, and snippets.

@drewlesueur
Created December 7, 2010 05:31
Show Gist options
  • Save drewlesueur/731506 to your computer and use it in GitHub Desktop.
Save drewlesueur/731506 to your computer and use it in GitHub Desktop.
polymorphism in go
//the terms "late binding", "dynamic binding", "polymorphism" kind of blur together for me
//here is an example of this concept in Go
package main
import "fmt"
type Animal interface {
Say()
}
type Dog struct {
}
func (d *Dog) Say() {
fmt.Println("Bark")
}
func test(a Animal) {
a.Say()
}
func main() {
dog := new(Dog)
test(dog)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment