Skip to content

Commit feac38b

Browse files
authored
Merge pull request #213 from A-caibird/patch-1
Update ch5-06.md
2 parents b8d7c32 + 8df9c12 commit feac38b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

ch5/ch5-06.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ strings.Map(func(r rune) rune { return r + 1 }, "HAL-9000")
1313
<u><i>gopl.io/ch5/squares</i></u>
1414
```Go
1515
// squares返回一个匿名函数。
16-
// 该匿名函数每次被调用时都会返回下一个数的平方。
16+
// 该匿名函数每次被调用时都会返回下一个数的平方的函数
1717
func squares() func() int {
1818
var x int
1919
return func() int {
@@ -23,10 +23,11 @@ func squares() func() int {
2323
}
2424
func main() {
2525
f := squares()
26-
fmt.Println(f()) // "1"
27-
fmt.Println(f()) // "4"
28-
fmt.Println(f()) // "9"
29-
fmt.Println(f()) // "16"
26+
// () 函数调用符号
27+
fmt.Println(f()()) // "1"
28+
fmt.Println(f()()) // "4"
29+
fmt.Println(f()()) // "9"
30+
fmt.Println(f()()) // "16"
3031
}
3132
```
3233

0 commit comments

Comments
 (0)