diff --git a/source/chapter1/04_revision_history.md b/source/chapter1/04_revision_history.md index 830bbc92..6c9ccbbc 100644 --- a/source/chapter1/04_revision_history.md +++ b/source/chapter1/04_revision_history.md @@ -3,14 +3,15 @@ ### 2019-01-24 * 更新到 Swift 5。 -* 添加了[动态调用](https://docs.swift.org/swift-book/ReferenceManual/Attributes.html#ID603)章节,其中包含有关使用 DynamicCallable 属性动态调用实例作为函数的信息。 -* 添加了 [unknown](https://docs.swift.org/swift-book/ReferenceManual/Attributes.html#ID605) 和[未来枚举匹配](https://docs.swift.org/swift-book/ReferenceManual/Statements.html#ID602)章节,其中包含了使用 `unknown` 来处理未来枚举可能发生改变的情形。 -* 在 [Key-Path] 表达式章节添加了标示 key path (\.self) 相关内容。 +* 增加了[拓展字符串分隔符](https://docs.swift.org/swift-book/LanguageGuide/StringsAndCharacters.html#ID606)部分,另外在[字符串字面量](https://docs.swift.org/swift-book/ReferenceManual/LexicalStructure.html#ID417)部分更新了拓展字符串分隔符相关内容。 +* 添加了[动态调用](https://docs.swift.org/swift-book/ReferenceManual/Attributes.html#ID603)章节,其中包含有关使用 `dynamicCallable` 属性动态调用实例作为函数的信息。 +* 添加了[unknown](https://docs.swift.org/swift-book/ReferenceManual/Attributes.html#ID605)和[未来枚举匹配](https://docs.swift.org/swift-book/ReferenceManual/Statements.html#ID602)章节,其中包含了使用 `unknown` 来处理未来枚举可能发生改变的情形。 +* 在[Key-Path]表达式章节添加了标示 key path (\.self) 相关内容。 * 在[可选编译块](https://docs.swift.org/swift-book/ReferenceManual/Statements.html#ID539)章节新增了小于比较符 `<` 相关内容。 ### 2018-09-17 -* 更新至 Swift 4.2 。 +* 更新至 Swift 4.2。 * 在[遍历枚举情形](https://docs.swift.org/swift-book/LanguageGuide/Enumerations.html#ID581)章节添加了访问所有枚举情形的内容。 * 在[编译诊断](https://docs.swift.org/swift-book/ReferenceManual/Statements.html#ID582)章节添加了有关 `#error` 和 `#warning` 相关内容。 * 在[属性声明](https://docs.swift.org/swift-book/ReferenceManual/Attributes.html#ID348)章节中补充了 `inlinable` 和 `usableFromInline` 属性相关的内联信息。 @@ -20,7 +21,7 @@ ### 2018-03-29 -* 更新至 Swift 4.1 +* 更新至 Swift 4.1。 * 在[等价运算符](https://docs.swift.org/swift-book/LanguageGuide/AdvancedOperators.html#ID45)章节添加了等价运算符的合成实现信息。 * 在[声明](https://docs.swift.org/swift-book/ReferenceManual/Declarations.html)一章的[申明拓展](https://docs.swift.org/swift-book/ReferenceManual/Declarations.html#ID378)部分和[协议](https://docs.swift.org/swift-book/LanguageGuide/Protocols.html)一章的[有条件地遵循协议](https://docs.swift.org/swift-book/LanguageGuide/Protocols.html#ID574)部分添加了协议的有条件遵循相关内容。 * 在[关联类型约束中使用协议](https://docs.swift.org/swift-book/LanguageGuide/Generics.html#ID575)章节中添加了递归协议约束的内容。 @@ -29,7 +30,7 @@ ### 2017-12-04 * 更新至 Swift 4.0.3。 -* 更新 [Key-Path](https://docs.swift.org/swift-book/ReferenceManual/Expressions.html#ID563) 表达式章节,现在 key path 支持下标子路径。 +* 更新[Key-Path](https://docs.swift.org/swift-book/ReferenceManual/Expressions.html#ID563)表达式章节,现在 key path 支持下标子路径。 ### 2017-09-19 @@ -47,7 +48,7 @@ * 更新至 Swift 3.1。 * 增加[范型 Where 子句扩展](https://docs.swift.org/swift-book/LanguageGuide/Generics.html#ID553),其中包含需要的扩展信息。 -* 增加了一个区间迭代的例子到 [For-In 循环](https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html#ID121)。 +* 增加了一个区间迭代的例子到[For-In 循环](https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html#ID121)。 * 增加一个可失败数值转换的例子[到可失败构造器](https://docs.swift.org/swift-book/LanguageGuide/Initialization.html#ID224)章节。 * 增加关于使用 Swift 语言版本的 `available` 特性内容到[声明特性](https://docs.swift.org/swift-book/ReferenceManual/Attributes.html#ID348)章节。 * 更新了[函数类型](https://docs.swift.org/swift-book/ReferenceManual/Types.html#ID449)章节中的描述,注意在写函数类型时不允许使用参数标签。 @@ -76,7 +77,7 @@ * 更新[泛型](https://docs.swift.org/swift-book/LanguageGuide/Generics.html)和[泛型形参和实参](https://docs.swift.org/swift-book/ReferenceManual/GenericParametersAndArguments.html)章节中[泛型 Where 语句](https://docs.swift.org/swift-book/LanguageGuide/Generics.html#ID192)部分,现在泛型的 where 语句写在一个声明的最后。 * 更新[逃逸闭包](https://docs.swift.org/swift-book/LanguageGuide/Closures.html#ID546)一节,现在闭包默认为非逃逸的(noescaping)。 * 更新[基础部分](https://docs.swift.org/swift-book/LanguageGuide/TheBasics.html)一章中[可选绑定](https://docs.swift.org/swift-book/LanguageGuide/TheBasics.html#ID333)部分和[语句](https://docs.swift.org/swift-book/ReferenceManual/Statements.html)一章中[While 语句](https://docs.swift.org/swift-book/ReferenceManual/Statements.html#ID432)部分,现在 if,`while` 和 `guard` 语句使用逗号分隔条件列表,不需要使用 `where` 语句。 -* 在[控制流](https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html)一章的[Switch](https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html#ID129)和[语句](https://docs.swift.org/swift-book/ReferenceManual/Statements.html)一章的 [Switch 语句](https://docs.swift.org/swift-book/ReferenceManual/Statements.html#ID436) 部分中增加关于 switch cases 可以使用多模式的信息。 +* 在[控制流](https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html)一章的[Switch](https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html#ID129)和[语句](https://docs.swift.org/swift-book/ReferenceManual/Statements.html)一章的[Switch 语句](https://docs.swift.org/swift-book/ReferenceManual/Statements.html#ID436)部分中增加关于 switch cases 可以使用多模式的信息。 * 更新[函数类型](https://docs.swift.org/swift-book/ReferenceManual/Types.html#ID449)一节,现在函数参数标签不包含在函数类型中。 * 更新[协议](https://docs.swift.org/swift-book/LanguageGuide/Protocols.html)一章[协议组合](https://docs.swift.org/swift-book/LanguageGuide/Protocols.html#ID282)部分和[类型](https://docs.swift.org/swift-book/ReferenceManual/Types.html)一章[协议组合类型](https://docs.swift.org/swift-book/ReferenceManual/Types.html#ID454)部分关于使用新的 Protocol1 & Protocol2 语法的信息。 * 更新动态类型表达式一节使用新的 `type(of:)` 表达式的信息。 @@ -122,25 +123,25 @@ * 更新了[字符串插值]和[字符串字面量]小节,现在字符串插值可包含字符串字面量。 * 增加了在[非逃逸闭包]一节中关于 `@noescape` 属性的相关内容。 * 更新了[声明特性]和[编译配置语句]小节中与 tvOS 相关的信息。 -* 增加了 [In-Out 参数]小节中与 in-out 参数行为相关的信息。 +* 增加了[In-Out 参数]小节中与 in-out 参数行为相关的信息。 * 增加了在[捕获列表]一节中关于指定闭包捕获列表被捕获时捕获值的相关内容。 * 更新了使用[可选链式调用访问属性]一节,阐明了如何通过可选链式调用进行赋值。 * 改进了[自动闭包]一节中对自闭包的讨论。 -* 在 [Swift 初见]()一节中更新了一个使用 `??` 操作符的例子。 +* 在[Swift 初见]()一节中更新了一个使用 `??` 操作符的例子。 ### 2015-09-16 -* 更新至 Swift 2.0 -* 在[错误处理](https://docs.swift.org/swift-book/LanguageGuide/ErrorHandling.html)一章中增加了关于错误处理的相关内容,包括 [Do 语句](https://docs.swift.org/swift-book/ReferenceManual/Statements.html#ID533)、[Throw 语句](https://docs.swift.org/swift-book/ReferenceManual/Statements.html#ID518)、[Defer 语句](https://docs.swift.org/swift-book/ReferenceManual/Statements.html#ID532)以及 [try 运算符](https://docs.swift.org/swift-book/ReferenceManual/Expressions.html#ID516) +* 更新至 Swift 2.0。 +* 在[错误处理](https://docs.swift.org/swift-book/LanguageGuide/ErrorHandling.html)一章中增加了关于错误处理的相关内容,包括[Do 语句](https://docs.swift.org/swift-book/ReferenceManual/Statements.html#ID533)、[Throw 语句](https://docs.swift.org/swift-book/ReferenceManual/Statements.html#ID518)、[Defer 语句](https://docs.swift.org/swift-book/ReferenceManual/Statements.html#ID532)以及[try 运算符](https://docs.swift.org/swift-book/ReferenceManual/Expressions.html#ID516)。 * 更新了[错误表示和抛出](https://docs.swift.org/swift-book/LanguageGuide/ErrorHandling.html#ID509)一节,现在所有类型都可以遵循 `ErrorType` 协议了。 * 在[将错误装换成可选值](https://docs.swift.org/swift-book/LanguageGuide/ErrorHandling.html#ID542)一节增加了 `try` 关键字相关信息。 * 在[枚举](https://docs.swift.org/swift-book/LanguageGuide/Enumerations.html)一章的[递归枚举](https://docs.swift.org/swift-book/LanguageGuide/Enumerations.html#ID536)部分以及以及[声明](https://docs.swift.org/swift-book/ReferenceManual/Declarations.html)一章的[任意类型用例的枚举](https://docs.swift.org/swift-book/ReferenceManual/Declarations.html#ID365)一节中新增了递归枚举相关信息。 -* 在[控制流](https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html)一章的 [API 可用性检查](https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html#ID523)一节和[语句](https://docs.swift.org/swift-book/ReferenceManual/Statements.html)一章的[可用性条件一节](https://docs.swift.org/swift-book/ReferenceManual/Statements.html#ID522)中增加了关于 API 可用性检查相关的内容。 -* 在[控制流](https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html)一章的 [尽早退出]()一节和[语句](https://docs.swift.org/swift-book/ReferenceManual/Statements.html)一章的 [Guard 语句]部分新增了与 `guard` 语句相关的内容。 +* 在[控制流](https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html)一章的[API 可用性检查](https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html#ID523)一节和[语句](https://docs.swift.org/swift-book/ReferenceManual/Statements.html)一章的[可用性条件一节](https://docs.swift.org/swift-book/ReferenceManual/Statements.html#ID522)中增加了关于 API 可用性检查相关的内容。 +* 在[控制流](https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html)一章的[尽早退出]()一节和[语句](https://docs.swift.org/swift-book/ReferenceManual/Statements.html)一章的[Guard 语句]部分新增了与 `guard` 语句相关的内容。 * 在[协议](https://docs.swift.org/swift-book/LanguageGuide/Protocols.html)一章中[协议扩展](https://docs.swift.org/swift-book/LanguageGuide/Protocols.html#ID521)一节中新增了关于协议扩展的内容。 * 在[访问控制](https://docs.swift.org/swift-book/LanguageGuide/AccessControl.html)一章的[单元测试 target 的访问级别](https://docs.swift.org/swift-book/LanguageGuide/AccessControl.html#ID519)一节中新增了关于单元测试访问控制相关的内容。 * 在[模式](https://docs.swift.org/swift-book/ReferenceManual/Patterns.html)一章的[可选模式](https://docs.swift.org/swift-book/ReferenceManual/Patterns.html#ID520)一节中增加了可选模式相关内容。 -* 更新了 [Repeat-While](https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html#ID126) 一节中关于 `repeat-while` 循环相关的内容。 +* 更新了[Repeat-While](https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html#ID126)一节中关于 `repeat-while` 循环相关的内容。 * 更新了[字符串和字符](https://docs.swift.org/swift-book/LanguageGuide/StringsAndCharacters.html)一章,现在 `String` 类型在 Swift 标准库中不再遵循 `CollectionType` 协议。 * 在[常量与变量打印](https://docs.swift.org/swift-book/LanguageGuide/TheBasics.html#ID314)一节中增加了新 Swift 标准库中关于 `print(_:separator:terminator)` 相关内容。 * 在[枚举](https://docs.swift.org/swift-book/LanguageGuide/Enumerations.html)一章中的[原始值的隐式赋值](https://docs.swift.org/swift-book/LanguageGuide/Enumerations.html#ID535)一节和[声明](https://docs.swift.org/swift-book/ReferenceManual/Declarations.html)一章的[包含原始值类型的枚举](https://docs.swift.org/swift-book/ReferenceManual/Declarations.html#ID366)一节中增加了关于包含 `String` 原始值的枚举用例的行为相关内容。 @@ -162,9 +163,9 @@ * 更新了[类型特性](https://docs.swift.org/swift-book/LanguageGuide/Properties.html#ID264)一节,提到了存储型特性其实是懒加载。 * 更新了[捕获类型](https://docs.swift.org/swift-book/LanguageGuide/Closures.html#ID103)一节,阐明了变量和常量在闭包中如何被捕获。 * 更新了[声明特性](https://docs.swift.org/swift-book/ReferenceManual/Attributes.html#ID348)一节,用以描述何时在类中使用 `@objc` 关键字。 -* 在[错误处理](https://docs.swift.org/swift-book/LanguageGuide/ErrorHandling.html#ID512)一节中增加了关于执行 `throw` 语句的性能的讨论。在 [Do 语句](https://docs.swift.org/swift-book/ReferenceManual/Statements.html#ID533)一节的 do 语句部分也增加了类似内容。 +* 在[错误处理](https://docs.swift.org/swift-book/LanguageGuide/ErrorHandling.html#ID512)一节中增加了关于执行 `throw` 语句的性能的讨论。在[Do 语句](https://docs.swift.org/swift-book/ReferenceManual/Statements.html#ID533)一节的 do 语句部分也增加了类似内容。 * 更新了[类型特性](https://docs.swift.org/swift-book/LanguageGuide/Properties.html#ID264)一节中关于类、结构体和枚举的存储型和计算型特性相关的内容。 -* 更新了 [Break 语句](https://docs.swift.org/swift-book/ReferenceManual/Statements.html#ID441)一节中关于带标签的 break 语句相关内容。 +* 更新了[Break 语句](https://docs.swift.org/swift-book/ReferenceManual/Statements.html#ID441)一节中关于带标签的 break 语句相关内容。 * 在[属性观察器](https://docs.swift.org/swift-book/LanguageGuide/Properties.html#ID262)一节中更新了一处注释,用来明确 `willSet` 和 `didSet` 观察器的行为。 * 在[访问级别](https://docs.swift.org/swift-book/LanguageGuide/AccessControl.html#ID5)一节中新增了关于 `private` 作用域的相关信息说明。 * 在[弱引用](https://docs.swift.org/swift-book/LanguageGuide/AutomaticReferenceCounting.html#ID53)一节中增加了关于弱应用在垃圾回收系统和 ARC 之间的区别的说明。 @@ -174,7 +175,7 @@ ### 2015-4-8 * 更新至 Swift 1.2。 -* Swift 现在自身提供了一个 `Set` 集合类型,更多信息请看 [Sets](https://docs.swift.org/swift-book/LanguageGuide/CollectionTypes.html#ID484)。 +* Swift 现在自身提供了一个 `Set` 集合类型,更多信息请看[Sets](https://docs.swift.org/swift-book/LanguageGuide/CollectionTypes.html#ID484)。 * `@autoclosure` 现在是一个参数声明的属性,而不是参数类型的属性。这里还有一个新的参数声明属性 `@noescape`。更多信息,请看[属性声明](https://docs.swift.org/swift-book/ReferenceManual/Attributes.html#ID348)。 * 对于类型属性和方法现在可以使用 `static` 关键字作为声明描述符,更多信息,请看[类型变量属性](https://docs.swift.org/swift-book/ReferenceManual/Declarations.html#ID483)。 * Swift 现在包含一个 `as?` 和 `as!` 的向下可失败类型转换运算符。更多信息,请看[协议遵循性检查](https://docs.swift.org/swift-book/LanguageGuide/Protocols.html#ID283)。 @@ -192,7 +193,7 @@ * 在构造器中,常量属性有且仅能被赋值一次。更多信息,请看[在构造过程中给常量属性赋值](https://docs.swift.org/swift-book/LanguageGuide/Initialization.html#ID212)。 * 多个可选绑定现在可以在`if`语句后面以逗号分隔的赋值列表的方式出现,更多信息,请看[可选绑定](https://docs.swift.org/swift-book/LanguageGuide/TheBasics.html#ID333)。 * 一个[可选链表达式](https://docs.swift.org/swift-book/ReferenceManual/Expressions.html#ID405)必须出现在后缀表达式中。 -* 协议类型转换不再局限于 `@obj` 修饰的协议了 +* 协议类型转换不再局限于 `@obj` 修饰的协议了。 * 在运行时可能会失败的类型转换可以使用 `as?` 和 `as!` 运算符,而确保不会失败的类型转换现在使用 `as` 运算符。更多信息,请看[类型转换运算符](https://docs.swift.org/swift-book/ReferenceManual/Expressions.html#ID388)。 ### 2014-10-16 @@ -212,18 +213,18 @@ * [断言](https://docs.swift.org/swift-book/LanguageGuide/TheBasics.html#ID335)现在可以使用字符串内插语法,并删除了文档中有冲突的注释。 * 更新了[连接字符串和字符](https://docs.swift.org/swift-book/LanguageGuide/StringsAndCharacters.html#ID291)小节来说明一个事实,那就是字符串和字符不能再用 `+` 号运算符或者复合加法运算符 `+=` 相互连接,这两种运算符现在只能用于字符串之间相连。请使用 `String` 类型的 `append` 方法在一个字符串的尾部增加单个字符。 * 在[属性申明](https://docs.swift.org/swift-book/ReferenceManual/Attributes.html#ID348)章节增加了关于 `availability` 特性的一些信息。 -* [可选类型](https://docs.swift.org/swift-book/LanguageGuide/TheBasics.html#ID330) 若有值时,不再隐式的转换为 `true`,同样,若无值时,也不再隐式的转换为 `false`,这是为了避免在判别 optional `Bool` 的值时产生困惑。 替代的方案是,用`==` 或 `!=` 运算符显式地去判断 Optinal 是否是 `nil`,以确认其是否包含值。 -* Swift 新增了一个 [Nil 合并运算符](https://docs.swift.org/swift-book/LanguageGuide/BasicOperators.html#ID72) (`a ?? b`), 该表达式中,如果 Optional `a` 的值存在,则取得它并返回,若 Optional `a`为`nil`,则返回默认值 `b` +* [可选类型](https://docs.swift.org/swift-book/LanguageGuide/TheBasics.html#ID330)若有值时,不再隐式的转换为 `true`,同样,若无值时,也不再隐式的转换为 `false`,这是为了避免在判别 optional `Bool` 的值时产生困惑。 替代的方案是,用`==` 或 `!=` 运算符显式地去判断 Optinal 是否是 `nil`,以确认其是否包含值。 +* Swift 新增了一个[Nil 合并运算符](https://docs.swift.org/swift-book/LanguageGuide/BasicOperators.html#ID72)(`a ?? b`), 该表达式中,如果 Optional `a` 的值存在,则取得它并返回,若 Optional `a`为`nil`,则返回默认值 `b` * 更新和扩展[字符串的比较](https://docs.swift.org/swift-book/LanguageGuide/StringsAndCharacters.html#ID298),用以反映和展示'字符串和字符的比较',以及'前缀(prefix)/后缀(postfix)比较'都开始基于扩展字符集(extended grapheme clusters)规范的等价比较。 * 现在,你可以通过下标赋值或者[可选调用链](https://docs.swift.org/swift-book/LanguageGuide/OptionalChaining.html)中的可变方法和操作符来给属性设值。相应地更新了有关[通过可选链接访问属性](https://docs.swift.org/swift-book/LanguageGuide/OptionalChaining.html#ID248)的信息,并扩展了[通过可选链接调用方法](https://docs.swift.org/swift-book/LanguageGuide/OptionalChaining.html#ID249)时检查方法调用成功的示例,以显示如何检查属性设置是否成功。 * 在章节可选链中,增加一个新的小节[访问可选类型的下标脚注](https://docs.swift.org/swift-book/LanguageGuide/OptionalChaining.html#ID251)。 * 更新章节[访问和修改数组](https://docs.swift.org/swift-book/LanguageGuide/CollectionTypes.html#ID110)以标示:从该版本起,不能再通过 `+=` 运算符给一个数组添加一个新的项。对应的替代方案是,使 `append` 方法,或者通过 `+=` 运算符来添加一个只有一个项的数组。 -* 添加了一个提示:在[范围运算符](https://docs.swift.org/swift-book/LanguageGuide/BasicOperators.html#ID73)中,比如, `a...b` 和 `a..<b` ,起始值 `a` 不能大于结束值 `b` 。 -* 重写了[继承](https://docs.swift.org/swift-book/LanguageGuide/Inheritance.html)这一章:删除了本章中关于构造器重写的介绍性报道;转而将更多的注意力放到新增的部分——子类的新功能,以及如何通过重写(overrides)修改已有的功能。另外,[重写属性的 Getters 和 Setters](https://docs.swift.org/swift-book/LanguageGuide/Inheritance.html#ID200) 中的例子已经被替换为展示如何重写一个 `description` 属性。 (而关于如何在子类的构造器中修改继承属性的默认值的例子,已经被移到[构造过程](https://docs.swift.org/swift-book/LanguageGuide/Initialization.html)这一章。) +* 添加了一个提示:在[范围运算符](https://docs.swift.org/swift-book/LanguageGuide/BasicOperators.html#ID73)中,比如, `a...b` 和 `a..