github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/gnovm/tests/files/method4.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 type Point struct { 10 Coord 11 z int 12 } 13 14 type Tpoint struct { 15 t int 16 Point 17 } 18 19 func main() { 20 o := Tpoint{0, Point{Coord{3, 4}, 5}} 21 println(o.dist()) 22 } 23 24 // Output: 25 // 25