Methods can be defined for either pointer or value receiver types. Here's an example of a value receiver.
()
| 16 | // Methods can be defined for either pointer or value |
| 17 | // receiver types. Here's an example of a value receiver. |
| 18 | func (r rect) perim() int { |
| 19 | return 2*r.width + 2*r.height |
| 20 | } |
| 21 | |
| 22 | func main() { |
| 23 | r := rect{width: 10, height: 5} |