修复IndexFunc函数签名错误 (#698)

This commit is contained in:
BuTn
2019-07-28 10:26:20 +08:00
committed by ᴊ. ᴄʜᴇɴ
parent 93401d1790
commit 4cf547665e

View File

@@ -28,7 +28,7 @@ func callback(y int, f func(int, int)) {
将函数作为参数的最好的例子是函数 `strings.IndexFunc()` 将函数作为参数的最好的例子是函数 `strings.IndexFunc()`
该函数的签名是 `func IndexFunc(s string, f func(c int) bool) int`,它的返回值是在函数 `f(c)` 返回 true、-1 或从未返回时的索引值。 该函数的签名是 `func IndexFunc(s string, f func(c rune) bool) int`,它的返回值是在函数 `f(c)` 返回 true、-1 或从未返回时的索引值。
例如 `strings.IndexFunc(line, unicode.IsSpace)` 就会返回 `line` 中第一个空白字符的索引值。当然,您也可以书写自己的函数: 例如 `strings.IndexFunc(line, unicode.IsSpace)` 就会返回 `line` 中第一个空白字符的索引值。当然,您也可以书写自己的函数: