From de4a848d6f7c5ca347e6d248de766e1ea167f124 Mon Sep 17 00:00:00 2001 From: Leo Date: Mon, 26 Dec 2016 19:51:31 +0800 Subject: [PATCH] fix sorted() (#674) --- source/chapter2/04_Collection_Types.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/source/chapter2/04_Collection_Types.md b/source/chapter2/04_Collection_Types.md index 6f2b3856..46d04ed6 100755 --- a/source/chapter2/04_Collection_Types.md +++ b/source/chapter2/04_Collection_Types.md @@ -12,10 +12,10 @@ > 校对:[shanks](http://codebuild.me) > 2.2 -> 校对:[SketchK](https://github.com/SketchK) 2016-05-11 -> -> 3.0 -> 校对:[shanks](http://codebuild.me) ,2016-10-09 +> 校对:[SketchK](https://github.com/SketchK) 2016-05-11 +> +> 3.0 +> 校对:[shanks](http://codebuild.me) ,2016-10-09 > 3.0.1,shanks,2016-11-12 @@ -23,7 +23,7 @@ - [集合的可变性](#mutability_of_collections) - [数组](#arrays) -- [集合](#sets) +- [集合](#sets) - [集合操作](#performing_set_operations) - [字典](#dictionaries) @@ -86,7 +86,7 @@ someInts = [] Swift 中的`Array`类型还提供一个可以创建特定大小并且所有数据都被默认的构造方法。我们可以把准备加入新数组的数据项数量(`count`)和适当类型的初始值(`repeating`)传入数组构造函数: ```swift -var threeDoubles = Array(repeating: 0.0, count: 3) +var threeDoubles = Array(repeating: 0.0, count: 3) // threeDoubles 是一种 [Double] 数组,等价于 [0.0, 0.0, 0.0] ``` @@ -96,7 +96,7 @@ var threeDoubles = Array(repeating: 0.0, count: 3) 我们可以使用加法操作符(`+`)来组合两种已存在的相同类型数组。新数组的数据类型会被从两个数组的数据类型中推断出来: ```swift -var anotherThreeDoubles = Array(repeating: 2.5, count: 3) +var anotherThreeDoubles = Array(repeating: 2.5, count: 3) // anotherThreeDoubles 被推断为 [Double],等价于 [2.5, 2.5, 2.5] var sixDoubles = threeDoubles + anotherThreeDoubles @@ -202,7 +202,7 @@ shoppingList[4...6] = ["Bananas", "Apples"] 调用数组的`insert(_:at:)`方法来在某个具体索引值之前添加数据项: ```swift -shoppingList.insert("Maple Syrup", at: 0) +shoppingList.insert("Maple Syrup", at: 0) // shoppingList 现在有7项 // "Maple Syrup" 现在是这个列表中的第一项 ``` @@ -448,7 +448,7 @@ let oddDigits: Set = [1, 3, 5, 7, 9] let evenDigits: Set = [0, 2, 4, 6, 8] let singleDigitPrimeNumbers: Set = [2, 3, 5, 7] -oddDigits.union(evenDigits).sort() +oddDigits.union(evenDigits).sorted() // [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] oddDigits. intersection(evenDigits).sorted() // []