github.com/HaHadaxigua/yaegi@v1.0.1/_test/method8.go (about)

     1  package main
     2  
     3  type Sample struct {
     4  	Name string
     5  	Foo  []string
     6  }
     7  
     8  func (s *Sample) foo(j int) {
     9  	for i, v := range s.Foo {
    10  		println(i, v)
    11  	}
    12  }
    13  
    14  var samples = []Sample{
    15  	Sample{"hello", []string{"world"}},
    16  }
    17  
    18  func main() {
    19  	samples[0].foo(3)
    20  }
    21  
    22  // Output:
    23  // 0 world