Swift weekly 2018/04/03

3f7d9611fc919c98512b779cde637dfc?s=47 Johnlin
April 03, 2018

Swift weekly 2018/04/03

3f7d9611fc919c98512b779cde637dfc?s=128

Johnlin

April 03, 2018
Tweet

Transcript

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

  2. From the core • Swift 4.1 and Xcode 9.3 is

    out
  3. Swift 4.1 & Xcode 9.3 • Conditional Conformance • Auto

    Equatable & Hashable • xccov : command line parser for Xcode coverage report.
  4. 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
  5. [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()
  6. [SE-0194] Derived Collection of Enum Cases • ৗৗ။۰౸धཁ iterate Enum

    ཫ໘㑌Ұݸ case త৘ گɻൺํ㘸૾ੋ๾ࠀṛతՖ৭ɻ • ݱࡏ୞ೳ༻ enum Suit : Int {} ࠶ኺᏐࣈိҰݸݸճਪ
  7. [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)
  8. [SE-0193] Cross-module inlining and specialization • Swift ݱࡏՄҎᯩଶฤᩄྃɻ • ෆաݱࡏ໛૊೭ؒᔒ༗࠷ՂԽɼر๬ະိՄҎҰى၏

    ࠷ՂԽɻ
  9. [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) } • Ҽҝੋࡏෆಉత໛૊ॴҎᔒ㭎๏࠷ՂԽɼ୞ೳরզ၇ ሜతฤᩄ
  10. [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 తݪ ࢝ᛰိ၏࠷ՂԽ
  11. [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..<a { res = add(res, b) } return res } • ෆա public ༗Մೳ။ݺڣଖଞവᏐɼ೗ՌṜࠣവᏐ໵૝ ࠷ՂԽɼबधཁՃ @usableFromInline
  12. [SE-0143] (मվ) Conditional Conformance • Conditional Conformance Ҹڐ generic ࡏ

    ᑍ݅ූ߹ తܗگԼ९॥๭ࠣ protocolɻ • Ꭿྫိ㘸ɼ let a = [[1]] let b = [[2]] a == b • ࡏ4.0 ။ᔒ㭎๏ compileɼࡏ 4.1 ੋ false
  13. [SE-0143] (मվ) Conditional Conformance • ෆա 4.1 ؐੋෆೳ၏Լ໘Ṝ݅ࣄ let h:

    [[Int] : Int] = [[1]: 1] • Ҽҝ Array ୞༗ conform Equatable, ୠੋཁᙛ Dict key धཁੋ Hashable . • 4.2 ೭ޙबՄҎྃ, Array, Dict, Optional ౎ՄҎɻ
  14. Community • Swift for TensorFlow • https://www.youtube.com/watch? list=PLQY2H8rRoyvxjVx3zfw4vA4cvlKogyLNN&v=Y ze693W4MaU

  15. 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
  16. Community • objc2swift • https://github.com/yahoojapan/objc2swift • objectivec2swift • https://objectivec2swift.com/#/home