Skip to content

Commit

Permalink
Update 06.2.7.md
Browse files Browse the repository at this point in the history
  • Loading branch information
hantmac committed Jun 26, 2019
1 parent 3321457 commit ae24348
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions eBook/chapter6/06.2.7.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 函数作为参数

Go 函数可以接收另一个 Go 函数作为参数,这个功能为您用 Go 函数增加了非常广泛的用途。这个功能最为常用的用途就是排序。这里介绍的 `funFun.go`,是一个非常简单的处理整数值的例子。相关代码分为三部分介绍。
Go 函数可以接收另一个 Go 函数作为参数,这个功能为您用 Go 函数增加了非常广泛的用途。这个功能最为常用的用途就是闭包。这里介绍的 `funFun.go`,是一个非常简单的处理整数值的例子。相关代码分为三部分介绍。

`funFun.go` 的第一部分代码如下:

Expand Down Expand Up @@ -44,7 +44,7 @@ func main() {

最后一个 `fmt.Println()` 表达式,奇妙的是:这个函数参数的实现定义在 `funFun()` 调用里!

尽管这个方法可以运行简单的,小巧的函数参数,但它不会对有许多行代码的函数表现的很好
尽管这个方法可以运行简单的,小巧的函数参数,对于多行代码的函数还是尽量不要这样使用

执行 `funFun.go` 将产生如下输出:

Expand All @@ -53,4 +53,4 @@ $go run funFun.go
function1: 246
function2: 15129
Inline: 1860867
```
```

0 comments on commit ae24348

Please sign in to comment.