修改部分描述,添加必要的标点符号,补充代码超链接 (#804)

This commit is contained in:
Jck
2021-10-25 23:34:42 +08:00
committed by GitHub
parent d5578df00a
commit 39dbdb7094
100 changed files with 433 additions and 414 deletions

View File

@@ -46,13 +46,13 @@ func main() {
// cannot use lst (type List) as type Appender in argument to CountInto:
// List does not implement Appender (Append method has pointer receiver)
// CountInto(lst, 1, 10)
if LongEnough(lst) { // VALID:Identical receiver type
if LongEnough(lst) { // VALID: Identical receiver type
fmt.Printf("- lst is long enough\n")
}
// A pointer value
plst := new(List)
CountInto(plst, 1, 10) //VALID:Identical receiver type
CountInto(plst, 1, 10) // VALID: Identical receiver type
if LongEnough(plst) {
// VALID: a *List can be dereferenced for the receiver
fmt.Printf("- plst is long enough\n")
@@ -68,7 +68,7 @@ func main() {
**总结**
在接口上调用方法时,必须有和方法定义时相同的接收者类型或者是可以具体类型 `P` 直接可以辨识的:
在接口上调用方法时,必须有和方法定义时相同的接收者类型或者是可以根据具体类型 `P` 直接辨识的:
- 指针方法可以通过指针调用
- 值方法可以通过值调用