diff --git a/eBook/10.6.md b/eBook/10.6.md index 523a97e..b891e0e 100644 --- a/eBook/10.6.md +++ b/eBook/10.6.md @@ -519,15 +519,15 @@ func (l *Log) 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 - Log:{1 - Yes we can! - 2 - After me the world will be a better place!} + Log:1 - Yes we can! + 2 - After me the world will be a better place! 内嵌的类型不需要指针,`Customer` 也不需要 `Add` 方法,它使用 `Log` 的 `Add` 方法,`Customer` 有自己的 `String` 方法,并且在它里面调用了 `Log` 的 `String` 方法。