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