Skip to content

Instantly share code, notes, and snippets.

@percybolmer
Created January 27, 2022 19:39
Show Gist options
  • Select an option

  • Save percybolmer/75d2ee47669785eea781798ae5b64ee5 to your computer and use it in GitHub Desktop.

Select an option

Save percybolmer/75d2ee47669785eea781798ae5b64ee5 to your computer and use it in GitHub Desktop.
// Person is a struct that accepts a type definition at initialization
// And uses that Type as the data type for meters as input
func (p Person[S]) Move(meters S) {
fmt.Printf("%s moved %d meters\n", p.Name, meters)
}
func (c Car[S]) Move(meters S) {
fmt.Printf("%s moved %d meters\n", c.Name, meters)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment