fix typo for 10.2.md

This commit is contained in:
david
2015-10-14 15:32:13 +08:00
parent 40e8a960cc
commit d07af6f7f5

View File

@@ -2,7 +2,7 @@
## 10.2.1 结构体工厂
Go 语言不支持面向对象编程语言中那样的构造子方法,但是可以很容易的在 Go 中实现 “构造子工厂“ 方法。为了方便通常会为类型定义一个工厂,惯例,工厂的名字以 new 或 New 开头。假设定义了如下的 File 结构体类型:
Go 语言不支持面向对象编程语言中那样的构造子方法,但是可以很容易的在 Go 中实现 “构造子工厂“ 方法。为了方便通常会为类型定义一个工厂,惯例,工厂的名字以 new 或 New 开头。假设定义了如下的 File 结构体类型:
```go
type File struct {
@@ -19,7 +19,7 @@ func NewFile(fd int, name string) *File {
return nil
}
return &File(id, name)
return &File(fd, name)
}
```