Created
July 22, 2020 19:49
-
-
Save cjavilla-stripe/3a2caee4883d98e65b122b5f66862107 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// ------ 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