github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/gnovm/tests/files/method12.gno (about)

     1  package main
     2  
     3  type Coord struct {
     4  	x, y int
     5  }
     6  
     7  func (c Coord) dist() int { return c.x*c.x + c.y*c.y }
     8  
     9  func main() {
    10  	o := Coord{3, 4}
    11  	f := o.dist
    12  	println(f())
    13  }
    14  
    15  // Output:
    16  // 25