mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 03:06:41 +08:00
Update 11.3.md (#467)
修改一些bug sq1 := new(Square)时, sq1是Square指针类型, 而下面方法实现也是指针类型, 所有应该写*Square
This commit is contained in:
@@ -83,7 +83,7 @@ func (ci *Circle) Area() float32 {
|
|||||||
The type of areaIntf is: *main.Square
|
The type of areaIntf is: *main.Square
|
||||||
areaIntf does not contain a variable of type Circle
|
areaIntf does not contain a variable of type Circle
|
||||||
|
|
||||||
程序行中定义了一个新类型 `Circle`,它也实现了 `Shaper` 接口。 `t, ok := areaIntf.(*Square); ok ` 测试 `areaIntf` 里是否一个包含 'Square' 类型的变量,结果是确定的;然后我们测试它是否包含一个 'Circle' 类型的变量,结果是否定的。
|
程序中定义了一个新类型 `Circle`,它也实现了 `Shaper` 接口。 `if t, ok := areaIntf.(*Square); ok ` 测试 `areaIntf` 里是否有一个包含 `*Square` 类型的变量,结果是确定的;然后我们测试它是否包含一个 `*Circle` 类型的变量,结果是否定的。
|
||||||
|
|
||||||
**备注**
|
**备注**
|
||||||
|
|
||||||
@@ -93,4 +93,4 @@ func (ci *Circle) Area() float32 {
|
|||||||
|
|
||||||
- [目录](directory.md)
|
- [目录](directory.md)
|
||||||
- 上一节:[接口嵌套接口](11.2.md)
|
- 上一节:[接口嵌套接口](11.2.md)
|
||||||
- 下一节:[类型判断:type-switch](11.4.md)
|
- 下一节:[类型判断:type-switch](11.4.md)
|
||||||
|
Reference in New Issue
Block a user