Swift weekly 2017/12/05

3f7d9611fc919c98512b779cde637dfc?s=47 Johnlin
December 05, 2017

Swift weekly 2017/12/05

3f7d9611fc919c98512b779cde637dfc?s=128

Johnlin

December 05, 2017
Tweet

Transcript

  1. Swift पใ 2017/12/05 John Lin @johnlinvc

  2. From the core • Swift ࿦ஃ

  3. Swift ࿦ஃ • ໨લ Swift ૬᮫త౼࿦౎ੋࡏ mailing list ্ɻ •

    ༗ᴍ೉၏፺ਘ೭ྨత • ༬ܭ 12 ݄த။Ҡ౸ࣗՍత Discourse ࿦ஃ্ɼ။೺ ᢜత mailing list 㚎༰Ҡաڈ
  4. Evolution • [SE-0187] Ճೖ Sequence.filterMap(_:) • [SE-0188] ᩋ Index Ꮣ੒

    Hashable • [SE-0189] ݶ੍ލ module త Struct init • [SE-0190] ฏ୆൑Ꮧ • [SE-0191] Ҡআ Collection త IndexDistance
  5. [SE-0187] Ճೖ Sequence.filterMap(_:) • ݱࡏSwift ༗ࡾछ flatMap • ୈҰछੋ࠷ৗݟతɼᩋၷ૚త Sequence

    Ꮣ Ұ૚
 let fm1 = [[1,2], [2,3]].flatMap { return $0 } fm1 //[1,2,2,3] • ୈೋछੋሣ Optional ཫ໘తᆴ၏ࣄ
 let opt : Int? = 1 let fm2 = opt.flatMap {return $0 == nil ? nil : $0!+1} // 2 • ୈࡾछੋ༻ိ೺ Seqence ཫ໘త nil ᖤᎃ
 let fm3 = [1,nil,2].flatMap{return $0} // [1,2]
  6. [SE-0187] Ճೖ Sequence.filterMap(_:) • ୈࡾछతߦҝ࿨໊᜝ሣෆىိ
 let fm3 = [1,nil,2].flatMap{return $0}

    // [1,2] • ॴҎཁվ੒࿨ Rust ؐ༗ Ocaml Ұᒬత໊᜝ 
 filterMap • ᢜత။ཹஶɼୠੋ။௓ Warning ࿨ fix-it
  7. [SE-0188] ᩋ Index Ꮣ੒ Hashable • ՄҎ༻Ꮠࣈత key path ኺ

    array ፤౦੢ let numbers = [10, 20, 30, 40, 50] let firstValue = \[Int].[0] print(numbers[keyPath: firstValue]) // 10 • ୠੋ༻ index ။ᆦᎃɼҼҝindex ෆੋ Hashable let string = "Helloooo!" let firstChar = \String.[string.startIndex] // error: subscript index of type 'String.Index' in a key path must be Hashable • ။೺ሏվ੒ Hashable
  8. [SE-0189] ݶ੍ލ module త 
 Struct init • ݱࡏՄҎ༻ extension

    㢨ผత module ཫత Struct Ճ init വᏐɼୠੋෆೳ㢨 class Ճ initɻ • ೗Ռ Struct Ճྃ৽త let ᏓᏐɼୠੋ extension ᔒڅ ଞᆴब။ᆦᎃɻ • Ҏޙ㢨ผత module త Struct Ճత init Ұఆཁݺڣ self.init(...)ɼෆવ Swift 4 ။༗ warning, 5 ။ Error
  9. [SE-0190] ฏ୆൑Ꮧ • ݱࡏཁ൑Ꮧੋෆੋ simulator ཁṜᒬሜ #if (arch(i386) || arch(x86_64))

    && (!os(macOS)) print("Simulator") #else print("Device") #endif • ೭ޙՄҎ௚઀༻ #if targetEnvironment(simulator) print("Simulator") #endif
  10. [SE-0191] Ҡআ Collection త IndexDistance • Collection ཫ໘༗Ұݸ associated type

    IndexDistance ༻ိදࣔ index ೭ؒతڑ཭త type • ࡏ 99.999999% త৘گԼ౎ੋ Int • መࡏ༗ᴍແ༻ɼ௚઀ઃ੒ Int
  11. Community • http://dlvm.org/ ׬શ༻ Swift ሜత Deep Learning • Google

    ਖ਼ࡏ։ᚙ Fuchsia ্త Swift https:// www.theverge.com/google/2017/11/20/16681556/ apple-swift-language-google-fuchsia-os-open- source
 https://github.com/apple/swift/pull/12955
  12. Community • Chris Lattner త Python Interop ౼࿦େፌ
 https://lists.swift.org/pipermail/swift-evolution/Week- of-Mon-20171127/041668.html