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

     1  package main
     2  
     3  import "fmt"
     4  
     5  type Foo struct{}
     6  
     7  func (Foo) Call() {
     8  	fmt.Println("Foo Called")
     9  }
    10  
    11  type Bar struct {
    12  	Foo
    13  }
    14  
    15  type Baz struct {
    16  	Foo
    17  }
    18  
    19  func (Baz) Call() {
    20  	fmt.Println("Baz Called")
    21  }
    22  
    23  func main() {
    24  	Foo{}.Call()
    25  	Bar{}.Call()
    26  	Baz{}.Call()
    27  }
    28  
    29  // Output:
    30  // Foo Called
    31  // Foo Called
    32  // Baz Called