Created
September 8, 2013 18:35
-
-
Save jcelliott/6487268 to your computer and use it in GitHub Desktop.
This file contains 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 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