Skip to content

Instantly share code, notes, and snippets.

@cjavilla-stripe
Created July 22, 2020 19:49
Show Gist options
  • Save cjavilla-stripe/3a2caee4883d98e65b122b5f66862107 to your computer and use it in GitHub Desktop.
Save cjavilla-stripe/3a2caee4883d98e65b122b5f66862107 to your computer and use it in GitHub Desktop.
// ------ py
class Robot:
# `self` in python is the instance
def move_forward(self, spaces=1):
print('Moving forward %d spaces' % (spaces))
r = Robot()
r.move_forward(2)
// ----- go
type Robot struct {}
// `r` is the "receiver" -- think instance
func (r Robot) MoveForward(spaces int) {
fmt.Printf("Move forward %d spaces\n", spaces)
}
r := Robot{}
r.MoveForward(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment