Merge pull request #658 from Andrew-liu/description
Update zh 02.4.md and 02.6.md
This commit is contained in:
@@ -130,7 +130,7 @@ Go语言中,也和C或者其他语言一样,我们可以声明新的类型
|
||||
|
||||

|
||||
|
||||
图2.7 Student和Human的方法继承
|
||||
图2.7 struct组合,Student组合了Human struct和string基本类型
|
||||
|
||||
我们看到Student访问属性age和name的时候,就像访问自己所有用的字段一样,对,匿名字段就是这样,能够实现字段的继承。是不是很酷啊?还有比这个更酷的呢,那就是student还能访问Human这个字段作为字段名。请看下面的代码,是不是更酷了。
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
## interface
|
||||
Go语言里面设计最精妙的应该算interface,它让面向对象,内容组织实现非常的方便,当你看完这一章,你就会被interface的巧妙设计所折服。
|
||||
### 什么是interface
|
||||
简单的说,interface是一组method的组合,我们通过interface来定义对象的一组行为。
|
||||
简单的说,interface是一组method签名的组合,我们通过interface来定义对象的一组行为。
|
||||
|
||||
我们前面一章最后一个例子中Student和Employee都能SayHi,虽然他们的内部实现不一样,但是那不重要,重要的是他们都能`say hi`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user