This commit is contained in:
Unknwon
2015-09-21 09:36:26 -04:00
parent 1ec25611bc
commit e62f886e92
2 changed files with 4 additions and 4 deletions

View File

@@ -113,9 +113,9 @@ type Interval struct {
初始化方式:
```go
intr := Interval(0, 3) (A)
intr := Interval(end:5, start:1) (B)
intr := Interval(end:5) (C)
intr := Interval{0, 3} (A)
intr := Interval{end:5, start:1} (B)
intr := Interval{end:5} (C)
```
A值必须以字段在结构体定义时的顺序给出**&** 不是必须的。B显示了另一种方式字段名加一个冒号放在值的前面这种情况下值的顺序不必一致并且某些字段还可以被忽略掉就像C中那样。

View File

@@ -198,7 +198,7 @@ type Interface interface {
a). 继续扩展程序,定义类型 `Triangle`,让它实现 `AreaInterface` 接口。通过计算一个特定三角形的面积来进行测试(三角形面积=0.5 * (底 * 高)
b). 定义一个新接口 `PeriInterface`,它有一个 `Perimeter` 接口。让 `Square` 实现这个接口,并通过一个 `Square` 示例来测试它。
b). 定义一个新接口 `PeriInterface`,它有一个 `Perimeter` 方法。让 `Square` 实现这个接口,并通过一个 `Square` 示例来测试它。
**练习 11.6** point_interfaces.go