Expression
Method values
A method value binds a receiver to a callable function. A value receiver is copied when the method value is created; a pointer receiver preserves the pointer, not an independent copy of its referent. Example output: '2 8'.
Formal Syntax & Structure
go syntaxgo
f := receiver.MethodWorking Example
Example Snippetgo
package main
import "fmt"
type Count int
func (c Count) Read() int { return int(c) }func main() { v := Count(2) f := v.Read v = 8 fmt.Println(f(), v.Read())}