mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 02:35:53 +08:00
@@ -62,7 +62,7 @@ func main() {
|
||||
|
||||
**讨论**
|
||||
|
||||
在 `lst` 上调用 `CountInto` 时会导致一个编译器错误,因为 `CountInto` 需要一个 `Appender`,而它的方法 `Append` 只定义在指针上。 在 `lst` 上调用 `LongEnough` 是可以的因为 'Len' 定义在值上。
|
||||
在 `lst` 上调用 `CountInto` 时会导致一个编译器错误,因为 `CountInto` 需要一个 `Appender`,而它的方法 `Append` 只定义在指针上。 在 `lst` 上调用 `LongEnough` 是可以的,因为 `Len` 定义在值上。
|
||||
|
||||
在 `plst` 上调用 `CountInto` 是可以的,因为 `CountInto` 需要一个 `Appender`,并且它的方法 `Append` 定义在指针上。 在 `plst` 上调用 `LongEnough` 也是可以的,因为指针会被自动解引用。
|
||||
|
||||
@@ -89,4 +89,4 @@ Go 语言规范定义了接口方法集的调用规则:
|
||||
|
||||
- [目录](directory.md)
|
||||
- 上一节:[测试一个值是否实现了某个接口](11.5.md)
|
||||
- 下一节:[第一个例子:使用 Sorter 接口排序](11.7.md)
|
||||
- 下一节:[第一个例子:使用 Sorter 接口排序](11.7.md)
|
||||
|
Reference in New Issue
Block a user