Programmeren in Go/Methodes

Uit Wikibooks

Programmeren in Go

Commentaar
Pakketten
Variabelen en constanten
Assignments
For
Switch
Functies
Defer
Arrays
Slices
Methodes
Types
Goroutines
Channels
Select

Methodes zijn in Go niks anders dan functies met een ontvanger. De ontvanger komt voor de naam van de functie.

func (o *ObjectType) FunctieNaam() (aanroep int) returnwaarde int {
}
// Dus
func (v *Vector2D) Optellen(w *Vector2D) {
    v.x = v.x + w.x
    v.y = v.y + w.y
}
Informatie afkomstig van https://nl.wikibooks.org Wikibooks NL.
Wikibooks NL is onderdeel van de wikimediafoundation.