blob: a7df04cec366f68e6cd6ab59d38367e41ab85148 [file] [log] [blame]
Ian Lance Taylor59e7a022012-02-03 16:38:59 -08001// 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.
Ian Lance Taylor59e7a022012-02-03 16:38:59 -08006
7package method4a
8
9type T1 int
10
11type T2 struct {
12 F int
13}
14
15type I1 interface {
16 Sum([]int, int) int
17}
18
19type I2 interface {
20 Sum(a []int, b int) int
21}
22
23func (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
31func (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}