Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第10章 #851

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eBook/10.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func (p Point3) Abs() float64 {

可以有连接到类型的方法,也可以有连接到类型指针的方法。

但是这没关系:对于类型 `T`,如果在 `\*T` 上存在方法 `Meth()`,并且 `t` 是这个类型的变量,那么 `t.Meth()` 会被自动转换为 `(&t).Meth()`。
但是这没关系:对于类型 `T`,如果在 `*T` 上存在方法 `Meth()`,并且 `t` 是这个类型的变量,那么 `t.Meth()` 会被自动转换为 `(&t).Meth()`。

**指针方法和值方法都可以在指针或非指针上被调用**,如下面程序所示,类型 `List` 在值上有一个方法 `Len()`,在指针上有一个方法 `Append()`,但是可以看到两个方法都可以在两种类型的变量上被调用。

Expand Down