github.com/karrick/go@v0.0.0-20170817181416-d5b0ec858b37/test/method4.dir/method4a.go (about)

     1  // Copyright 2012 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Test method expressions with arguments.
     6  
     7  package method4a
     8  
     9  type T1 int
    10  
    11  type T2 struct {
    12  	F int
    13  }
    14  
    15  type I1 interface {
    16  	Sum([]int, int) int
    17  }
    18  
    19  type I2 interface {
    20  	Sum(a []int, b int) int
    21  }
    22  
    23  func (i T1) Sum(a []int, b int) int {
    24  	r := int(i) + b
    25  	for _, v := range a {
    26  		r += v
    27  	}
    28  	return r
    29  }
    30  
    31  func (p *T2) Sum(a []int, b int) int {
    32  	r := p.F + b
    33  	for _, v := range a {
    34  		r += v
    35  	}
    36  	return r
    37  }