github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/gnovm/tests/files/type37c.gno (about) 1 package main 2 3 import "fmt" 4 5 type Integer int 6 7 func (i *Integer) Add(x int) { // receiver is val, not ptr 8 println(int(*i) + x) 9 } 10 11 func main() { 12 a := new(Integer) 13 a.Add(4) 14 15 fmt.Println(*a) 16 } 17 18 // Output: 19 // 4 20 // 0