Slide 1

Slide 1 text

Swift पใ 2018/04/02 John Lin @johnlinvc

Slide 2

Slide 2 text

From the core • Swift 4.1 and Xcode 9.3 is out

Slide 3

Slide 3 text

Swift 4.1 & Xcode 9.3 • Conditional Conformance • Auto Equatable & Hashable • xccov : command line parser for Xcode coverage report.

Slide 4

Slide 4 text

Evolution • [SE-0199] Adding toggle to Bool • [SE-0194] Derived Collection of Enum Cases • [SE-0193] Cross-module inlining and specialization • [SE-0143] (मվ) Conditional Conformance

Slide 5

Slide 5 text

[SE-0199] Adding toggle to Bool • cart.items[0].discount.valid = 
 !cart.item[0].discount[0].valid • 4.2 ՄҎ༻ • cart.items[0].discount.valid.toggle()

Slide 6

Slide 6 text

[SE-0194] Derived Collection of Enum Cases • ৗৗ။۰౸धཁ iterate Enum ཫ໘㑌Ұݸ case త৘ گɻൺํ㘸૾ੋ๾ࠀṛతՖ৭ɻ • ݱࡏ୞ೳ༻ enum Suit : Int {} ࠶ኺᏐࣈိҰݸݸճਪ

Slide 7

Slide 7 text

[SE-0194] Derived Collection of Enum Cases • ೭ޙՄҎ༻
 enum Suit : CaseIterable {case heart, spade, diamond, club} • बՄҎ፤౸ॴ༗తՖ৭
 Suit.allCases //[heart, spade, diamon, club] • ෆաલఏੋ case ෆೳ༗ attribute, rectangle(5,6)

Slide 8

Slide 8 text

[SE-0193] Cross-module inlining and specialization • Swift ݱࡏՄҎᯩଶฤᩄྃɻ • ෆաݱࡏ໛૊೭ؒᔒ༗࠷ՂԽɼر๬ະိՄҎҰى၏ ࠷ՂԽɻ

Slide 9

Slide 9 text

[SE-0193] Cross-module inlining and specialization // library public func mul(_ a:Int, _ b:Int) -> Int { return a * b } // user func mul(_ a:Int,_ b:Int,_ c:Int) -> Int { return mul(mul(a,b),c) } • Ҽҝੋࡏෆಉత໛૊ॴҎᔒ㭎๏࠷ՂԽɼ୞ೳরզ၇ ሜతฤᩄ

Slide 10

Slide 10 text

[SE-0193] Cross-module inlining and specialization // library @_inlineable public func mul(_ a:Int, _ b:Int) -> Int { return a * b } // user func mul(_ a:Int,_ b:Int,_ c:Int) -> Int { return mul(mul(a,b),c) // a * b * c } • Ճྃ @inlineable ೭ޙɼฤᩄثबՄҎ፤౸ mul తݪ ࢝ᛰိ၏࠷ՂԽ

Slide 11

Slide 11 text

[SE-0193] Cross-module inlining and specialization @usableFromInline func add(_ a:Int, _ b: Int) -> Int { return a + b } @inlineable public func mul(_ a:Int, _ b:Int) -> Int { var res = 0 for _ in 0..

Slide 12

Slide 12 text

[SE-0143] (मվ) Conditional Conformance • Conditional Conformance Ҹڐ generic ࡏ ᑍ݅ූ߹ తܗگԼ९॥๭ࠣ protocolɻ • Ꭿྫိ㘸ɼ let a = [[1]] let b = [[2]] a == b • ࡏ4.0 ။ᔒ㭎๏ compileɼࡏ 4.1 ੋ false

Slide 13

Slide 13 text

[SE-0143] (मվ) Conditional Conformance • ෆա 4.1 ؐੋෆೳ၏Լ໘Ṝ݅ࣄ let h: [[Int] : Int] = [[1]: 1] • Ҽҝ Array ୞༗ conform Equatable, ୠੋཁᙛ Dict key धཁੋ Hashable . • 4.2 ೭ޙबՄҎྃ, Array, Dict, Optional ౎ՄҎɻ

Slide 14

Slide 14 text

Community • Swift for TensorFlow • https://www.youtube.com/watch? list=PLQY2H8rRoyvxjVx3zfw4vA4cvlKogyLNN&v=Y ze693W4MaU

Slide 15

Slide 15 text

Community • LOLCode literal for swift 
 https://github.com/apple/swift/pull/15664/ files#diff-8ec25bd1041bc5e833d0451725039b7cR 1
 https://forums.swift.org/t/pitch-lolcode/11565 • https://zh.wikipedia.org/zh-tw/LOLCODE

Slide 16

Slide 16 text

Community • objc2swift • https://github.com/yahoojapan/objc2swift • objectivec2swift • https://objectivec2swift.com/#/home