Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Swift weekly 2018/01/02

Johnlin
January 02, 2018

Swift weekly 2018/01/02

Johnlin

January 02, 2018
Tweet

More Decks by Johnlin

Other Decks in Programming

Transcript

  1. [SE-0187] Ճೖ Sequence.compactMap(_:) • ݱࡏ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]
  2. [SE-0187] Ճೖ Sequence.compactMap(_:) • ୈࡾछతߦҝ࿨໊᜝ሣෆىိ
 let fm3 = [1,nil,2].flatMap{return $0}

    // [1,2] • ॴҎཁվ੒࿨ Rust ؐ༗ Ocaml Ұᒬత໊᜝ 
 filterMap • ॴҎཁվ੒࿨ Ruby ൺֱ૾త໊᜝ 
 compactMap • ᢜత။ཹஶɼୠੋ။௓ Warning ࿨ fix-it
  3. Community • Chris Lattner త Python Interop ౼࿦େፌ ֢Լྃ۟ ᴍɼܾఆॄኄ໵ෆվɻ

    • https://lists.swift.org/pipermail/swift-evolution/Week- of-Mon-20171218/042262.html