mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 00:43:26 +08:00
修改部分描述,添加必要的标点符号,补充代码超链接 (#804)
This commit is contained in:
@@ -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` 直接辨识的:
|
||||
|
||||
- 指针方法可以通过指针调用
|
||||
- 值方法可以通过值调用
|
||||
|
Reference in New Issue
Block a user