Skip to content

Commit

Permalink
Merge pull request #219 from gopl-zh/revert-213-patch-1
Browse files Browse the repository at this point in the history
Revert "Update ch5-06.md"
  • Loading branch information
chai2010 authored Apr 3, 2024
2 parents feac38b + 687fb92 commit fa27be9
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions ch5/ch5-06.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ strings.Map(func(r rune) rune { return r + 1 }, "HAL-9000")
<u><i>gopl.io/ch5/squares</i></u>
```Go
// squares返回一个匿名函数。
// 该匿名函数每次被调用时都会返回下一个数的平方的函数
// 该匿名函数每次被调用时都会返回下一个数的平方。
func squares() func() int {
var x int
return func() int {
Expand All @@ -23,11 +23,10 @@ func squares() func() int {
}
func main() {
f := squares()
// () 函数调用符号
fmt.Println(f()()) // "1"
fmt.Println(f()()) // "4"
fmt.Println(f()()) // "9"
fmt.Println(f()()) // "16"
fmt.Println(f()) // "1"
fmt.Println(f()) // "4"
fmt.Println(f()) // "9"
fmt.Println(f()) // "16"
}
```

Expand Down

0 comments on commit fa27be9

Please sign in to comment.