Update 10.6.md (#790)

This commit is contained in:
Kang Jing
2021-03-02 01:30:03 +08:00
committed by GitHub
parent 8a11cc7eb4
commit a01ea97327

View File

@@ -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` 方法。