jweinst1
11/12/2016 - 8:41 PM

uses pointer method receiver as instance method

uses pointer method receiver as instance method

package main

import "fmt"

type val struct {
	i int
	nxt * val
}
//uses pointer method reciever to modify instance of a struct
func (self *val) add(i int) {
	self.i += i
}



func main() {
	m := val{1, nil}
	m.add(6)
  fmt.Println(m)
}