From 9fece2a889009714e966cc0c1598fcf413c7931b Mon Sep 17 00:00:00 2001 From: punchdrunker Date: Sun, 2 Sep 2018 13:20:20 +0900 Subject: [PATCH] Revert "Merge pull request #24 from svartalfheim/work/apply-swift4-to-1.1" This reverts commit fc10c808099dd9bd20e008948c48c8f5e7382b8f, reversing changes made to f623f13ce52369f913ad4866a12bbf225cde20a6. --- .../1.1/HelloWorld.playground/Contents.swift | 4 ++-- .../xcshareddata/IDEWorkspaceChecks.plist | 8 -------- .../xcshareddata/IDEWorkspaceChecks.plist | 8 -------- .../day1/1.1/Users.playground/Contents.swift | 14 ++++++------- .../xcshareddata/IDEWorkspaceChecks.plist | 8 -------- .../xcshareddata/IDEWorkspaceChecks.plist | 8 -------- .../xcshareddata/IDEWorkspaceChecks.plist | 8 -------- .../xcshareddata/IDEWorkspaceChecks.plist | 8 -------- Swift/pages/day1/1-1_swift-basics.md | 20 +++---------------- 9 files changed, 11 insertions(+), 75 deletions(-) delete mode 100644 Swift/after/day1/1.1/HelloWorld.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist delete mode 100644 Swift/after/day1/1.1/JSON.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist delete mode 100644 Swift/after/day1/1.1/Users.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist delete mode 100644 Swift/before/day1/1.1/HelloWorld.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist delete mode 100644 Swift/before/day1/1.1/JSON.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist delete mode 100644 Swift/before/day1/1.1/Users.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/Swift/after/day1/1.1/HelloWorld.playground/Contents.swift b/Swift/after/day1/1.1/HelloWorld.playground/Contents.swift index 128749be..b906146f 100644 --- a/Swift/after/day1/1.1/HelloWorld.playground/Contents.swift +++ b/Swift/after/day1/1.1/HelloWorld.playground/Contents.swift @@ -26,12 +26,12 @@ print(helloWorld) //模範解答2 /* * [h, ell, o, world]は[String?]型なので - * compactMapで[String]型に変換し、[String]型の + * flatMapで[String]型に変換し、[String]型の * public func joined(separator: String = default) -> String * を使って内部のstringを結合する。 * ※ループさせる回数が増える */ -let helloWorld2: String = [h, ell, o, world].compactMap { $0 }.joined() +let helloWorld2: String = [h, ell, o, world].flatMap { $0 }.joined() print(helloWorld2) diff --git a/Swift/after/day1/1.1/HelloWorld.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Swift/after/day1/1.1/HelloWorld.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d98100..00000000 --- a/Swift/after/day1/1.1/HelloWorld.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/Swift/after/day1/1.1/JSON.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Swift/after/day1/1.1/JSON.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d98100..00000000 --- a/Swift/after/day1/1.1/JSON.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/Swift/after/day1/1.1/Users.playground/Contents.swift b/Swift/after/day1/1.1/Users.playground/Contents.swift index 93a06a05..8e558cd7 100644 --- a/Swift/after/day1/1.1/Users.playground/Contents.swift +++ b/Swift/after/day1/1.1/Users.playground/Contents.swift @@ -18,13 +18,11 @@ class User: CustomStringConvertible { * print時に実装したdescriptionが出力されます。 */ var description: String { - return """ - \nUser: - \tname = \(name) - \tera = \(era) - \tage = \(age) - \tvisits = \(String(describing: visits))\n - """ + return "\nUser:\n" + + " name = \(name)\n" + + " era = \(era)\n" + + " age = \(age)\n" + + " visits = \(visits)\n" } init?(dict: [String : Any?]) { @@ -76,5 +74,5 @@ let dict: [String : [[String : Any?]]] = [ ] //usersのarrayを取得し、flatMapを使ってUser型に変換 -let users: [User] = (dict["users"] ?? []).compactMap { User(dict: $0) } +let users: [User] = (dict["users"] ?? []).flatMap { User(dict: $0) } print(users) diff --git a/Swift/after/day1/1.1/Users.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Swift/after/day1/1.1/Users.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d98100..00000000 --- a/Swift/after/day1/1.1/Users.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/Swift/before/day1/1.1/HelloWorld.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Swift/before/day1/1.1/HelloWorld.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d98100..00000000 --- a/Swift/before/day1/1.1/HelloWorld.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/Swift/before/day1/1.1/JSON.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Swift/before/day1/1.1/JSON.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d98100..00000000 --- a/Swift/before/day1/1.1/JSON.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/Swift/before/day1/1.1/Users.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Swift/before/day1/1.1/Users.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d98100..00000000 --- a/Swift/before/day1/1.1/Users.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/Swift/pages/day1/1-1_swift-basics.md b/Swift/pages/day1/1-1_swift-basics.md index 14cf4c1e..37bcd22d 100644 --- a/Swift/pages/day1/1-1_swift-basics.md +++ b/Swift/pages/day1/1-1_swift-basics.md @@ -14,7 +14,6 @@ |2016年03月|Swift 2.2| |2016年12月|Swiftオープンソース化 [swift.org](https://swift.org/)| |2016年09月|Swift 2.3、Swift 3.0| -|2017年09月|Swift 4.0| APIの振る舞いに関して疑問を持ったら、[公式API Reference](https://developer.apple.com/reference)を見ましょう。 またはXcodeのソースコード上で型にカーソルをあわせて`command`を押しながらクリックすると @@ -53,7 +52,7 @@ Int.max 123+456 //579 123 + 456 //579 123+ 456 //error: '+' is not a postfix unary operator -123 +456 //error: consecutive statements on a line must be separated by ';' +123 +456 //error: ambiguous use of operator '+' ``` ## 文字列 @@ -70,16 +69,6 @@ print("Hello World!") print("Hello " + "World!") ``` -Swift4からは複数行での文字列定義に対応しました。 - -```swift -print(""" -Hello -World -!!! -""") -``` - ## `let`と`var` Swiftでは`var`で変数を、`let`で定数を宣言できます。 @@ -433,7 +422,7 @@ struct Person { ## propertyの値を監視 -`willSet`や`didSet`を使うことで、propertyの値の変更を監視することができます。 +`wiiSet`や`didSet`を使うことで、propertyの値の変更を監視することができます。 ```swift class Person { @@ -713,7 +702,7 @@ Swift3では、C言語スタイルのfor文と`++`及び`--`が使用できな for var i = 0; i < 10 ; i++ { print(i) } -// error: C-style for statement has been removed in Swift 3 +// 0 1 2 3 4 5 6 7 8 9 ``` ```swift @@ -897,9 +886,6 @@ print(dog as! PoliceDog) ## Access Control -swift4からは`private`が`extension`内からもアクセスできるように変更になりました -> 参考 [Improve Interaction Between private Declarations and Extensions](https://github.com/apple/swift-evolution/blob/master/proposals/0169-improve-interaction-between-private-declarations-and-extensions.md#detailed-design) - |アクセス修飾子|内容| |:---|:---| |open|同じモジュールだけでなく、別のモジュールからもアクセスができ、別のモジュールで継承またはオーバーライドができる|