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

     1  package main
     2  
     3  type foo struct {
     4  	bar string
     5  }
     6  
     7  func (f foo) String() string {
     8  	return "Hello from " + f.bar
     9  }
    10  
    11  type Stringer interface {
    12  	String() string
    13  }
    14  
    15  func main() {
    16  	var f Stringer = foo{bar: "bar"}
    17  	println(f)
    18  }
    19  
    20  // Output:
    21  // Hello from bar