1
2
3
4
5
6
7
8
9
10 package main
11
12 type pa []int
13
14 type p int
15
16 func (this *pa) func1() (v *p, c int) {
17 for _ = range *this {
18 c++
19 }
20 v = (*p)(&c)
21 return
22 }
23
24 func (this *pa) func2() p {
25 return (*p).func3(this.func1())
26 }
27
28 func (this *p) func3(f int) p {
29 return *this
30 }
31
32 func (this *pa) func2dots() p {
33 return (*p).func3(this.func1())
34 }
35
36 func (this *p) func3dots(f ...int) p {
37 return *this
38 }
39
40 func main() {
41 arr := make(pa, 13)
42 length := arr.func2()
43 if int(length) != len(arr) {
44 panic("length != len(arr)")
45 }
46 length = arr.func2dots()
47 if int(length) != len(arr) {
48 panic("length != len(arr)")
49 }
50 }
51
View as plain text