From 20b60b4224a9b1f4cdb33d04db948793f7e0df50 Mon Sep 17 00:00:00 2001 From: Hong Duan Date: Wed, 10 Aug 2016 13:23:37 +0800 Subject: [PATCH] Patch (#635) * Update 14_Initialization.md * Update 21_Extensions.md * Update 22_Protocols.md --- source/chapter2/14_Initialization.md | 4 ++-- source/chapter2/21_Extensions.md | 2 +- source/chapter2/22_Protocols.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/chapter2/14_Initialization.md b/source/chapter2/14_Initialization.md index 37d3fb76..16f73f68 100755 --- a/source/chapter2/14_Initialization.md +++ b/source/chapter2/14_Initialization.md @@ -610,7 +610,7 @@ let mysteryMeat = Food() // mysteryMeat 的名字是 [Unnamed] ``` -类层级中的第二个类是`Food`的子类`RecipeIngredient`。`RecipeIngredient`类构建了食谱中的一味调味剂。它引入了`Int`类型的属性`quantity`(以及从`Food`继承过来的`name`属性),并且定义了两个构造器来创建`RecipeIngredient`实例: +类层级中的第二个类是`Food`的子类`RecipeIngredient`。`RecipeIngredient`类用来表示食谱中的一项原料。它引入了`Int`类型的属性`quantity`(以及从`Food`继承过来的`name`属性),并且定义了两个构造器来创建`RecipeIngredient`实例: ```swift class RecipeIngredient: Food { @@ -647,7 +647,7 @@ let oneBacon = RecipeIngredient(name: "Bacon") let sixEggs = RecipeIngredient(name: "Eggs", quantity: 6) ``` -类层级中第三个也是最后一个类是`RecipeIngredient`的子类,叫做`ShoppingListItem`。这个类构建了购物单中出现的某一种调味料。 +类层级中第三个也是最后一个类是`RecipeIngredient`的子类,叫做`ShoppingListItem`。这个类构建了购物单中出现的某一种食谱原料。 购物单中的每一项总是从未购买状态开始的。为了呈现这一事实,`ShoppingListItem`引入了一个布尔类型的属性`purchased`,它的默认值是`false`。`ShoppingListItem`还添加了一个计算型属性`description`,它提供了关于`ShoppingListItem`实例的一些文字描述: diff --git a/source/chapter2/21_Extensions.md b/source/chapter2/21_Extensions.md index 66433c9a..1ed93023 100644 --- a/source/chapter2/21_Extensions.md +++ b/source/chapter2/21_Extensions.md @@ -297,7 +297,7 @@ func printIntegerKinds(numbers: [Int]) { print("") } printIntegerKinds([3, 19, -27, 0, -6, 0, 7]) -// 打印 “+ + - 0 - 0 +” +// 打印 “+ + - 0 - 0 + ” ``` 函数 `printIntegerKinds(_:)` 接受一个 `Int` 数组,然后对该数组进行迭代。在每次迭代过程中,对当前整数的计算型属性 `kind` 的值进行评估,并打印出适当的描述。 diff --git a/source/chapter2/22_Protocols.md b/source/chapter2/22_Protocols.md index 6fefd5ba..ad3a04ee 100644 --- a/source/chapter2/22_Protocols.md +++ b/source/chapter2/22_Protocols.md @@ -798,7 +798,7 @@ for _ in 1...4 { // 12 ``` -上述代码新建了一个 `Counter` 实例,并将它的数据源设置为一个 `TreeSource` 的实例,然后调用 `increment()` 方法四次。和预期一样,每次调用都会将 `count` 的值增加 `3`. +上述代码新建了一个 `Counter` 实例,并将它的数据源设置为一个 `ThreeSource` 的实例,然后调用 `increment()` 方法四次。和预期一样,每次调用都会将 `count` 的值增加 `3`. 下面是一个更为复杂的数据源 `TowardsZeroSource`,它将使得最后的值变为 `0`: