$30 off During Our Annual Pro Sale. View Details »

Swift 5 Exclusivity Enforcement

darquro
February 12, 2019

Swift 5 Exclusivity Enforcement

darquro

February 12, 2019
Tweet

More Decks by darquro

Other Decks in Technology

Transcript

  1. Re:valua t ion https://fril.jp/ L ead & Delight User F

    irst Ownership Fail Smart 4XJGU&YDMVTJWJUZ&OGPSDFNFOU 'FCUI BU4XJGUѪ޷ձWPM
  2. .PCJMF&OHJOFFS 3BLVUFO JOD   "CPVU.F :VLJ,VSPEB !EBSRVSP !EBSRVSP

  3. None
  4.   4XJGU&YDMVTJWJUZ&OGPSDFNFOU IUUQTTXJGUPSHCMPHTXJGUFYDMVTJWJUZ

  5. #BDLHSPVOE  

  6.   #BDLHSPVOE 4XJGUͰ͸ϝϞϦ҆શੑΛ୲อ͢ΔͨΊʹɺ ഉଞతΞΫηε͕ඞཁ

  7.   #BDLHSPVOE func modifyTwice(_ value: inout Int, by modifier:

    (inout Int) -> ()) { modifier(&value) modifier(&value) } func testCount() { var count = 1 modifyTwice(&count) { $0 += count } print(count) }
  8.   #BDLHSPVOE func modifyTwice(_ value: inout Int, by modifier:

    (inout Int) -> ()) { modifier(&value) modifier(&value) } func testCount() { var count = 1 modifyTwice(&count) { $0 += count } print(count) } 0WFSMBQQJOHBDDFTTFTUPDPVOU CVUNPEJpDBUJPOSFRVJSFTFYDMVTJWF BDDFTTDPOTJEFSDPQZJOHUPBMPDBMWBSJBCMF
  9.   #BDLHSPVOE w ಉ࣌ΞΫηεʹରͯ͠ίϯύΠϥ͸ಈ࡞Λอূ͠ͳ͍ w ίϯύΠϥͷΦϓςΟϚΠθʔγϣϯʹΑΓɺ༧ଌͰ ͖ͳ͍ಈ࡞ʹͳΔ͜ͱ͕͋Δɻ w 4XGJU͸ͰഉଞతΞΫηεͷڧ੍Λಋೖͨ͠ɻ

       4& IUUQTHJUIVCDPNBQQMFTXJGUFWPMVUJPOCMPCNBTUFSQSPQPTBMTFOGPSDF FYDMVTJWFBDDFTTUPNFNPSZNE
  10.   #BDLHSPVOE ίϯύΠϥͷഉଞతΞΫηεͷڧ੍ w ίϯύΠϧ࣌νΣοΫ $PNQJMFUJNF  w ࣮ߦ࣌νΣοΫ

    3VOUJNF 
  11.   #BDLHSPVOE 4XJGU 4XJGU $PNQJMFUJNF %FCVH#VJME 3FMFBTF#VJME %FCVH#VJME 3FMFBTF#VJME

    3VOUJNF %FCVH#VJME %FCVH#VJME 3FMFBTF#VJME ഉଞతϝϞϦΞΫηεͷEFGBVMUઃఆ
  12. *NQBDUPO4XJGU1SPKFDUT  

  13.   *NQBDUPO4XJGU1SPKFDUT طଘϓϩδΣΫτ΁ͷӨڹ w ഉଞϧʔϧʹҧ൓͍ͯͯ͠ɺσόοάςετͰ࣮ߦͰ ͖ͳ͔ͬͨίʔυʹରͯ͠Ϋϥογϡ͢ΔՄೳੑ w ύϑΥʔϚϯεʹӨڹ͕ͰΔՄೳੑ͕͋Δɻ w

    ಛʹϧʔϓॲཧʹ͓͍ͯҟͳΔΦϒδΣΫτؒͰΞΫηε͢Δ৔߹ʹ஫ҙ͢Δɻ w ΫϥεͷϓϩύςΟͳͲ͸QSJWBUFͱ͔JOUFSOBMʹ͢Δ͜ͱͰίϯύΠϥʹ໌ࣔతʹ఻ ͑ΔͳͲ͕ඞཁɻ
  14.   *NQBDUPO4XJGU1SPKFDUT 9DPEFͰ͸l&YDMVTJWF"DDFTTUP.FNPSZzͰมߋͰ͖Δ͕ɺ ύϑΥʔϚϯε༏ઌͷͨΊͷϦϦʔεϏϧυͰແޮʹ͢Δ͜ͱ͸ ਪ঑͠ͳ͍ɻ Ϋϥογϡ΍ϝϞϦഁյͳͲ༧ظ͠ͳ͍ڍಈΛট͘Մೳੑ

  15. &YBNQMFT  

  16.   &YBNQMF func modifyTwice(_ value: inout Int, by modifier:

    (inout Int) -> ()) { modifier(&value) modifier(&value) } func testCount() { var count = 1 let incrementBy = count modifyTwice(&count) { $0 += incrementBy } print(count) }
  17.   &YBNQMF func modifyTwice(_ value: inout Int, by modifier:

    (inout Int) -> ()) { modifier(&value) modifier(&value) } var count = 1 modifyTwice(&count) { $0 += count } print(count) 4JNVMUBOFPVTBDDFTTUPY CVUNPEJpDBUJPOSFRVJSFTFYDMVTJWFBDDFTT
  18. .PUJWBUJPO  

  19.   .PUJWBUJPO  ϓϩάϥϜͷن໛͕େ͖͘ͳΔʹͭΕɺͲ͜ͰͲ͏஋ ͕มߋ͞ΕΔͷ͔ঢ়ଶ͕༧ଌͰ͖ͳ͍  ݴޠ࢓༷ͱͯ͠༧ଌෆೳͳৼΔ෣͍Λഉআ  "#*҆ఆੑʹෆՄܽ

     ύϑΥʔϚϯεͷ࠷దԽ  0XOFSTIJQͱNPWFPOMZUZQFTʹඞཁ
  20. ·ͱΊ  

  21.   4XJGU&YDMVTJWJUZ&OGPSDFNFOU w 4XJGUͰ͸ഉଞతϝϞϦΞΫηεͷ࣮ߦ࣌νΣοΫ͕ ϦϦʔεϏϧυͰσϑΥϧτ༗ޮͱͳΔ w 4XJGUͷ҆શੑɺݎ࿚ੑ͕ڧԽ w ύϑΥʔϚϯεʹର͢ΔΦϓςΟϚΠθʔγϣϯͷ޲্

  22.   5IBOLZPVGPSMJTUFOJOH