mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-11 22:06:51 +08:00
Update 10.6.md (#790)
This commit is contained in:
@@ -519,15 +519,15 @@ func (l *Log) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Customer) String() string {
|
func (c *Customer) String() string {
|
||||||
return c.Name + "\nLog:" + fmt.Sprintln(c.Log)
|
return c.Name + "\nLog:" + fmt.Sprintln(c.Log.String())
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
输出:
|
输出:
|
||||||
|
|
||||||
Barak Obama
|
Barak Obama
|
||||||
Log:{1 - Yes we can!
|
Log:1 - Yes we can!
|
||||||
2 - After me the world will be a better place!}
|
2 - After me the world will be a better place!
|
||||||
|
|
||||||
内嵌的类型不需要指针,`Customer` 也不需要 `Add` 方法,它使用 `Log` 的 `Add` 方法,`Customer` 有自己的 `String` 方法,并且在它里面调用了 `Log` 的 `String` 方法。
|
内嵌的类型不需要指针,`Customer` 也不需要 `Add` 方法,它使用 `Log` 的 `Add` 方法,`Customer` 有自己的 `String` 方法,并且在它里面调用了 `Log` 的 `String` 方法。
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user