1.4.2 方法 加入关于结构体继承顺位的说明
chenjinya opened this issue · 2 comments
chenjinya commented
var cp ColoredPoint
cp.X = 1
fmt.Println(cp.Point.X) // "1"
cp.Point.Y = 2
fmt.Println(cp.Y) // "2"
这个例子很好,但是希望加一个关于结构体继承顺位的说明,比如
type A struct {
AA int
}
type B struct {
A
AA int
BB int
}
...
var b B
b.AA = 1
b.BB = 2
fmt.Println(b)
这时候打印出来的是 {{0} 1 2}
chai2010 commented
本书的定位是Go圣经的补充,而且也不可能覆盖全部的细节(那种属于参考手册),本书也不希望重复很多雷同话题。
鱼和熊掌不可兼得,语言的设计是特性的取舍和平衡,写书也一样
chenjinya commented
理解。