diff --git a/source/chapter1/03_revision_history.md b/source/chapter1/03_revision_history.md index 35d513bf..8e99b586 100644 --- a/source/chapter1/03_revision_history.md +++ b/source/chapter1/03_revision_history.md @@ -32,45 +32,46 @@
- Optionals no longer implicitly evaluate to true when they have a value and false when they do not, to avoid confusion when working with optional Bool values. Instead, make an explicit check against nil with the == or != operators to find out if an optional contains a value.
+ 可选类型(Optionals) 若有值时,不再隐式的转换为 true,同样,若无值时,也不再隐式的转换为 false, 这是为了避免在判别 optional Bool 的值时产生困惑。 替代的方案是,用== 或 != 运算符显式地去判断Optinal是否是 nil,以确认其是否包含值。
- Swift now has a Nil Coalescing Operator (a ?? b), which unwraps an optional’s value if it exists, or returns a default value if the optional is nil.
+ Swift新增了一个 Nil合并运算符(Nil Coalescing Operator) (a ?? b), 该表达式中,如果Optional a的值存在,则取得它并返回,若Optional a为nil,则返回默认值 b
- Updated and expanded the Comparing Strings section to reflect and demonstrate that string and character comparison and prefix / suffix comparison are now based on Unicode canonical equivalence of extended grapheme clusters. + 更新和扩展 字符串的比较(Comparing Strings) 章节,用以反映和展示'字符串和字符的比较',以及'前缀(prefix)/后缀(postfix)比较'都开始基于扩展字符集(extended grapheme clusters)规范的等价比较.
- You can now try to set a property’s value, assign to a subscript, or call a mutating method or operator through Optional Chaining. The information about Accessing Properties Through Optional Chaining has been updated accordingly, and the examples of checking for method call success in Calling Methods Through Optional Chaining have been expanded to show how to check for property setting success. + 现在,你可以通过 可选链(Optional Chaining)来:给属性设值,将其赋给一个下标脚注(subscript); 或调用一个变异(mutating)方法或运算符。对此,章节——通过可选链访问属性(Accessing Properties Through Optional Chaining)的内容已经被相应的更新。而章节——通过可选链调用方法(Calling Methods Through Optional Chaining中,关于检查方法调用是否成功的例子,已被扩展为展示如何检查一个属性是否被设值成功。 +
- Added a new section about Accessing Subscripts of Optional Type through optional chaining. + 在章节可选链中,增加一个新的小节 访问可选类型的下标脚注(Accessing Subscripts of Optional Type)
- Updated the Accessing and Modifying an Array section to note that you can no longer append a single item to an array with the += operator. Instead, use the append method, or append a single-item array with the += operator.
+= 运算符给一个数组添加一个新的项。. 对应的替代方案是, 使append 方法, 或者通过+=运算符来添加一个只有一个项的数组(single-item Array).
- Added a note that the start value a for the Range Operators a...b and a..<b must not be greater than the end value b.
+ 添加了一个提示:在 范围运算符(Range Operators)中,比如, a...b 和 a..<b ,起始值a不能大于结束值b.
- Rewrote the Inheritance chapter to remove its introductory coverage of initializer overrides. This chapter now focuses more on the addition of new functionality in a subclass, and the modification of existing functionality with overrides. The chapter’s example of Overriding Property Getters and Setters has been rewritten to show how to override a description property. (The examples of modifying an inherited property’s default value in a subclass initializer have been moved to the Initialization chapter.)
+ 重写了继承(Inheritance) 这一章:删除了这一章中关于构造器覆盖的介绍性报道;转而将更多的注意力放到新增的部分——子类的新功能,以及如何通过覆盖修改已有的功能。另外,小节 重写对象)属性的的Getters和Setters(Overriding Property Getters and Setters) 中的例子已经被替换为展示如何重写一个 description 属性. (而关于如何在子类的构造器中修改继承属性的默认值的例子,已经被移到继承 继承(Initialization) 这一章.)
- Updated the Initializer Inheritance and Overriding section to note that overrides of a designated initializer must now be marked with the override modifier.
+ 更新了 构造器的集成与覆盖(Initializer Inheritance and Overriding) 小节以标示: 重写一个特定的构造器必须使用 override 修改器.
- Updated the Required Initializers section to note that the required modifier is now written before every subclass implementation of a required initializer, and that the requirements for required initializers can now be satisfied by automatically inherited initializers.
+ 更新 Required构造器(Required Initializers) 小节以标示:required 修改器现在需要出现在所有子类的required构造器的声明中, 而required构造器的实现,现在可以仅使用自动集成的部分。
- Infix Operator Functions no longer require the @infix attribute.
+ 中置(Infix)的 运算符函数(Operator Functions) 不再需要@infix 属性.
- The @prefix and @postfix attributes for Prefix and Postfix Operators have been replaced by prefix and postfix declaration modifiers.
+ 前置和后置运算符(Prefix and Postfix Operators)的@prefix 和 @postfix 属性,已变更为 prefix 和 postfix 声明修改器(declaration modifiers).
- Added a note about the order in which Prefix and Postfix Operators are applied when both a prefix and a postfix operator are applied to the same operand. + 增加一条注解:当Prefix和postfix运算符被作用于同一个操作数时,关于前置和后置运算符(Prefix and Postfix Operators)的顺序(postfix运算符会先被执行)
- Operator functions for Compound Assignment Operators no longer use the @assignment attribute when defining the function.
+ 在运算符函数(Operator functions)中, 组合赋值运算符(Compound Assignment Operators) 不再使用 @assignment 属性来定义函数.
在这个版本中,在定义自定义操作符(Custom Operators) 时,修改器(Modifiers)的出现顺序发生变化。比如, 现在,你该编写 prefix operator, 而不是 operator prefix.