Skip to content

Instantly share code, notes, and snippets.

@jcelliott
Created September 8, 2013 18:35
Show Gist options
  • Save jcelliott/6487268 to your computer and use it in GitHub Desktop.
Save jcelliott/6487268 to your computer and use it in GitHub Desktop.
package main
import "fmt"
type Vehicle struct{}
func (v Vehicle) Move() {
fmt.Println("vehicle moving")
}
type Boat struct {
// embed the "superclass" as an unnamed struct member
Vehicle
}
func (b Boat) Move() {
b.Vehicle.Move()
fmt.Println("boat moving")
}
func main() {
new(Boat).Move()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment