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

Optional(2018)年...その後

 Optional(2018)年...その後

Hideaki Tamai

July 26, 2018
Tweet

More Decks by Hideaki Tamai

Other Decks in Technology

Transcript

  1. 0QUJPOBM

    ͦͷޙ
    )JEFBLJ5BNBJ
    1PUBUPUJQT+VMZ

    View full-size slide

  2. ࣗݾ঺հ
    )JEFBLJ5BNBJ
    ɾ.POFZ'PSXBSE *OD
    ɾJ04ΞϓϦΤϯδχΞ
    ɾ͘͘͢͢ʂࢠҭͯΤϯδχΞ.FFUVQ
    UBNBEPO
    !UBNBEPO

    View full-size slide

  3. IUUQTNPOFZGPSXBSEDPNFOHJOFFST@CMPHPQUJPOBM
    0QUJPOBM
    ೥͚͋·͓ͯ͠ΊͰͱ͏͍͟͝·͢

    View full-size slide

  4. ͜ΕΛػʹXBSOJOHΛ๾໓͢΂͘
    ౰ࣾJ04ΤϯδχΞ͕
    ෦ॺΛӽ͑ͯऔΓ૊Έ·ͨ͠
    ௨ৗͷػೳ։ൃͱฒߦͯ͠໿ϲ݄

    View full-size slide

  5. ΍ͬͨ͜ͱͦͷ̍
    4XJGU-JOU
    "VUPDPSSFDU

    View full-size slide

  6. Πϯσϯτͷௐ੔͚͔ͩͱࢥͬͯͨΒɺ
    ؆୯ͳwarning͸मਖ਼ͯ͘͠Εͨ
    func validate(_ input :(hoge: Fuga)) throws -> Void {
    func validate(_ input :(hoge: Fuga)) throws {

    View full-size slide

  7. ΍ͬͨ͜ͱͦͷ̎
    γϡοͱ௚ͤͦ͏ͳXBSOJOHΛফ͢

    View full-size slide

  8. - public final class Hoge: Fuga {
    + public class Hoge: Fuga {
    - network.request(request) { _ in }
    + _ = network.request(request) { _ in }
    ྫʣ͜͏͍͏΍ͭ

    View full-size slide

  9. ͋ͱ͸ͪͪ͘͘஍ಓʹ
    XBSOJOHΛͭͿ͍ͯͬͨ͠

    View full-size slide

  10. ਏ͔ͬͨ΍ͭ

    View full-size slide

  11. Ұ෦ͷϥΠϒϥϦ͕$PDPB1PET
    ܦ༝͡Όͳ͍ํ๏Ͱಋೖͯ͋͠Δ
    ʢେ൒͸$PDPB1PETܦ༝ʣ
    wͲͷόʔδϣϯΛ࢖ͬͯΔ͔෼͔Βͳ͍ͷͰ࠷৽ʹΞο
    ϓσʔτͨ࣌͠ͷӨڹൣғ͕ݟ͑ͣɺΞοϓσʔτ͠
    ͯྑ͍ͷ͔ෆ໌
    w͔͠΋Ұ෦ಠ࣮ࣗ૷Λ௥Ճͯ͠࢖ͬͯΔ΍ͭ΋͋Δ

    View full-size slide

  12. ಠ࣮ࣗ૷Λ௥Ճͯ͠ͳ͍
    ϥΠϒϥϦ
    wϥΠϒϥϦͷόʔδϣϯΛίϛοτϩά͔Βਪଌ
    ͠ӨڹൣғΛௐࠪ
    w$PDPB1PETʹҠߦ

    View full-size slide

  13. ಠ࣮ࣗ૷Λ௥Ճͯ͠Δ
    ϥΠϒϥϦ
    w൚༻తͳػೳ௥ՃͩͬͨͷͰɺϥΠϒϥϦΛGPSL͠
    ͯຊՈʹQVMMSFRVFTUΛग़ͨ͠
    wऔΓࠐ·Εͳ͔ͬͨϥΠϒϥϦ͸GPSLFESFQPTJUPSZ
    ͷϥΠϒϥϦΛ$PDPB1PETͰΠϯετʔϧ

    View full-size slide

  14. After
    Ϗϧυʹ͔͔Δ͕࣌ؒϝνϟ୹ॖ͞Εͨ
    XBSOJOH࡟আ͚ͩͰͳ͘ɺ4XJGUରԠ΍
    ίϯύΠϧΦϓγϣϯͷมߋ΋ޮՌ͕͋ͬͨͱࢥΘΕΔ

    View full-size slide

  15. ࠷ޙͷXBSOJOH
    ՝ۚͷϨγʔτ͕J04ܗࣜ
    ˠݱࡏରԠத

    View full-size slide

  16. XBSOJOHΛ૿΍͞ͳ͍
    औΓ૊Έ

    View full-size slide

  17. Ұྫ
    ɾϏϧυ࣌ʹ4XJGU-JOU"VUPDPSSFDU࣮ߦ
    ɾϏϧυʹNTҎ্͔͔͍ͬͯΔॲཧͰXBSOJOH
    ɾ4JEFSʢNJTTQFMMʣಋೖ
    ɾ%BOHFSಋೖ

    View full-size slide

  18. ·ͱΊ
    w ݹ͔͘Βӡ༻͞Ε͍ͯΔϓϩμΫτͰ΋ؤுͬͯऔΓ૊Ί͹ɺXBSOJOHΛ
    ΄΅̌ʹग़དྷΔ
    w Ϗϧυ୹ॖͷऔΓ૊Έ΋ग़དྷͯϏϧυ͕࣌ؒ෼෼·Ͱ୹ॖग़དྷͨ
    w ෦ॺΛ·͍ͨͰXBSOJOH๾໓ʹऔΓ૊ΜͩͷͰɺࣾ಺ͷJ04ΤϯδχΞ಺Ͱ
    XBSOJOH΍ϦϑΝΫλϦϯάʹର͢Δҙ͕ࣝߴ·ͬͨ
    w XBSOJOHΛݮΒͯ͠ຬ଍͢ΔͷͰ͸ͳ͘ɺ૿΍͞ͳ͍࢓૊Έͷߏங͕େࣄ

    View full-size slide

  19. ͝ਗ਼ௌ͋Γ͕ͱ͏͟͝
    ͍·ͨ͠

    View full-size slide