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

     1  package main
     2  
     3  type s struct{}
     4  
     5  func (s) hello() string {
     6  	return "hello"
     7  }
     8  
     9  func main() {
    10  	var v interface{}
    11  	v = s{}
    12  	switch v := v.(type) {
    13  	case interface{ hello() string }:
    14  		println(v.hello())
    15  	default:
    16  		panic("should not happen")
    17  	}
    18  }
    19  
    20  // Output:
    21  // hello