Anonymous user
Call an object method: Difference between revisions
→{{header|Go}}
(→{{header|Go}}: added class/instance distinction) |
|||
Line 30:
=={{header|Go}}==
Go distances itself from the word "object" and from many object oriented concepts. It does however have methods. Any user-defined type in Go can have methods and these work very much like "
Go has no direct equivalent to class methods.
<lang go>type Foo int // some custom type
// method on the type itself; can be called on that type or its pointer
func (self Foo) ValueMethod(x int) { }
// method on the pointer to the type; can be called on pointers
func (self *Foo) PointerMethod(x int) { }
|