Call an object method: Difference between revisions

Content added Content deleted
(added smalltalk)
(→‎{{header|Go}}: added class/instance distinction)
Line 30: Line 30:


=={{header|Go}}==
=={{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 "class methods" of object oriented languages. The examples below illustrate details of Go methods and thus represent the concept of class methods.

Go has no direct equivalent to instance methods. Instead, cases where you might first think to use instance methods can likely be handled with Go interfaces, functions as first class objects, functions as struct members, or functions as closures.
<lang go>type Foo int // some custom type
<lang go>type Foo int // some custom type