Curriculum Types & methods Methods exercise 5 · fill-word
Methods
Inside a method body, the receiver acts as the conventional
self-reference — Go has no this. Type the field-access
expression that reads the receiver's n field.
TypeScript reference
Fill the blanks →
About this theme
Methods are functions with a receiver — a special argument declared before the function name: func (r Receiver) Foo() { ... }. Two flavours: value receivers (operate on a copy) and pointer receivers (operate on the original). The rule of thumb: use a pointer receiver if you'd modify the receiver, or if the receiver is large enough that copying is wasteful.