Slide 1

Slide 1 text

ۚ ू·Ε4XJGU޷͖ʂ4XJGUѪ޷ձεϐϯΦϑ88%$ηογϣϯཁ໿ձ!ΦϯϥΠϯ !UIF@VIPPJ 8IBUTOFXJO4XJGUͷ ཁ໿💡

Slide 2

Slide 2 text

΢ϗʔΠ J04ΞϓϦΤϯδχΞ w ͱ͖Ͳ͖4XJGUѪ޷ձͷ 
 ӡӦʹࢀՃ͍ͯ͠Δ w ೥࿈ଓճ໨ w ݄ʹస৬ͨ͠

Slide 3

Slide 3 text

ͷ৽ػೳʢશൠɾδΣωϦΫεʣʹ͍ͭͯ࿩͠·͢ 4XJGU

Slide 4

Slide 4 text

શൠ

Slide 5

Slide 5 text

4& JGMFUߏจΛলུͯ͠ॻ͚Δ let foo: Int? = 0 let bar: String? = "bar" // Swift 5.6 if let foo = foo { ... } guard let bar = bar else { ... }

Slide 6

Slide 6 text

4& JGMFUߏจΛলུͯ͠ॻ͚Δ let foo: Int? = 0 let bar: String? = "bar" // Swift 5.7 if let foo { ... } guard let bar else { ... }

Slide 7

Slide 7 text

4& Ϋϩʔδϟ಺͕ෳ਺ͷจͰ΋ɺҾ਺ͱ໭Γ஋ͷܕΛলུͰ͖Δ func map(fn: (Int) -> T) -> T { fn(42) } // Swift 5.6 _ = map { value -> Double in print("Foo") return Double(value) }

Slide 8

Slide 8 text

4& Ϋϩʔδϟ಺͕ෳ਺ͷจͰ΋ɺҾ਺ͱ໭Γ஋ͷܕΛলུͰ͖Δ func map(fn: (Int) -> T) -> T { fn(42) } // Swift 5.7 _ = map { print("Foo") return Double(value) }

Slide 9

Slide 9 text

δΣωϦΫε

Slide 10

Slide 10 text

4& δΣωϦοΫؔ਺ͷҾ਺ʹσϑΥϧτ஋ΛࢦఆͰ͖Δ struct Foo: Equatable { static let shared = Foo() } // Swift 5.6 final class Bar { private let foo: F init(foo: F) { self.foo = foo } convenience init() where F == Foo { self.init(foo: .shared) } }

Slide 11

Slide 11 text

4& δΣωϦοΫؔ਺ͷҾ਺ʹσϑΥϧτ஋ΛࢦఆͰ͖Δ struct Foo: Equatable { static let shared = Foo() } // Swift 5.7 final class Bar { private let foo: F init(foo: F = Foo.shared) { self.foo = foo } }

Slide 12

Slide 12 text

4& ࿈૝ܕΛ࣋ͭϓϩτίϧΛܕͱͯ͠࢖͑Δ // Swift 5.6 protocol Foo {} protocol Bar { associatedtype FooType: Foo func foo() -> FooType } struct FooStruct: Foo {} struct BarStruct: Bar { func foo() -> FooStruct { .init() } } struct AnyBar { private let _foo: () -> B.FooType init(_ base: B) { _foo = { base.foo() } } } extension AnyBar: Bar { func foo() -> B.FooType { _foo() } } let bar: AnyBar = .init(BarStruct()) _ = bar.foo()

Slide 13

Slide 13 text

4& ࿈૝ܕΛ࣋ͭϓϩτίϧΛܕͱͯ͠࢖͑Δ let bar: any Bar = BarStruct() _ = bar.foo() // Swift 5.7 protocol Foo {} protocol Bar { associatedtype FooType: Foo func foo() -> FooType } struct FooStruct: Foo {} struct BarStruct: Bar { func foo() -> FooStruct { .init() } }

Slide 14

Slide 14 text

4& ؔ਺ͷҾ਺ʹsome͕࢖͑Δ // Swift 5.6 func foo(_ v1: V1, _ v2: V2) -> some View { // ... }

Slide 15

Slide 15 text

4& ؔ਺ͷҾ਺ʹsome͕࢖͑Δ // Swift 5.7 func foo(_ v1: some View, _ v2: some View) -> some View { // ... }

Slide 16

Slide 16 text

4& ϓϩτίϧʹࢁΧοίͰؔ࿈ܕΛॻ͚Δ // Swift 5.6 protocol Graph { associatedtype Foo associatedtype Bar } struct GraphStruct: Graph { typealias Foo = Int typealias Bar = String } protocol TestProtocol { func bar(_: G, foo: F) -> [B] where G: Graph, G.Foo == F, G.Bar == B } extension Graph where Foo == Int, Bar == String { // ... }

Slide 17

Slide 17 text

4& ϓϩτίϧʹࢁΧοίͰؔ࿈ܕΛॻ͚Δ // Swift 5.7 protocol Graph { associatedtype Foo associatedtype Bar } struct GraphStruct: Graph { typealias Foo = Int typealias Bar = String } protocol TestProtocol { func bar(_: some Graph, foo: F) -> [B] } extension Graph { // ... } final class Test { // Swift 5.6 Ͱ͸࣮ݱͰ͖ͳ͍ func build() -> some Graph { GraphStruct() } }

Slide 18

Slide 18 text

·ͱΊ w ίʔυͷهड़ྔ͕ݮΔݴޠ࢓༷͕૿͑ͨ w δΣωϦΫε͕ڧԽ͞ΕɺΑΓ௚ײతʹهड़Ͱ͖ΔΑ͏ʹͳͬͨ w someͱanyΛ࢖͏ͱಡΈ΍͍͢