This commit is contained in:
Xargin
2016-09-30 21:56:19 +08:00
parent 25eec00705
commit 853e2ad052
6 changed files with 10 additions and 10 deletions

View File

@@ -2,7 +2,7 @@
拥有函数名的函数只能在包级语法块中被声明通过函数字面量function literal我们可绕过这一限制在任何表达式中表示一个函数值。函数字面量的语法和函数声明相似区别在于func关键字后没有函数名。函数值字面量是一种表达式它的值被成为匿名函数anonymous function
函数字面量允许我们在使用函数时再定义它。通过这种技巧我们可以改写之前对strings.Map的调用
函数字面量允许我们在使用函数时再定义它。通过这种技巧我们可以改写之前对strings.Map的调用
```Go
strings.Map(func(r rune) rune { return r + 1 }, "HAL-9000")