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

Swift weekly 2018/09/04

Johnlin
September 04, 2018

Swift weekly 2018/09/04

Johnlin

September 04, 2018
Tweet

More Decks by Johnlin

Other Decks in Programming

Transcript

  1. Swift 5: Start your engines • Release date: Late 2018

    • ໨ඪ: ABI stability (again) ɼแؚ generic, API resilience, memory ownership model • ။޲Լ૬༰ 4
  2. Evolution • [SE-0220] count(where:) • [SE-0224] Support 'less than' operator

    in compilation conditions • [SE-0225] isEven, isOdd, isMultiple • [SE-0226] Package Manager Target Based Dependency Resolution
  3. [SE-0220] count(where:) • ཁዎᒬᏐ [1,2,3,4,5,6,7] ཫ໘༗ଟগۮᏐ䏆ʁ [1,2,3,4,5,6,7].filter { $0 %

    2 == 0 }.count • Ṝᒬతሜ๏ଖመ䋯తൺֱຫɼfilter ။ઌ䋯Ұ࣍᫮ ᅲɼ count ။࠶䋯Ұ࣍
  4. [SE-0220] count(where:) [1,2,3,4,5,6,7].reduce(0) { $0 + ($1 % 2 ==

    0 ? 1 : 0) } • Ṝᒬతሜ๏䋯తൺֱշɼୠੋ኷೉䔟㣛ੋࡏ၏ॄኄɻ
  5. [SE-0220] count(where:) var count = 0 for n in [1,2,3,4,5,6,7]

    { count += n % 2 == 0 ? 1 : 0 } • ࿨ reduce Ұᒬշɼෆա޷௕ɻ
  6. [SE-0224] Support 'less than' operator in compilation conditions #if swift(>=5.0)

    print("this is 5.0") #endif • ݱࡏՄҎ༻্໘తํ๏ိ൑Ꮧ Swift ൛ຊ • ෆա୞ೳ༻ >=ɼཁখԙ୞ೳ༻ ! ိᒾҰෆੋ >= #if !swift(>=5.0) print("this is not 5.0") #endif
  7. [SE-0224] Support 'less than' operator in compilation conditions #if swift(<5.0)

    print("this is not 5.0") #endif • ೭ޙՄҎ༻ < ိ൑Ꮧ Swift ൛ຊ
  8. [SE-0225] isEven, isOdd, isMultiple • ᧷ಘ㑌࣍౎ཁሜ n % 2 ==

    0 ኷൥䆩ʁ • େՈ᧷ಘ -3 % 2 ੋଟগ䏆ʁ
  9. [SE-0225] isEven, isOdd, isMultiple • ༗ਓఏҊཁՃ n.isEven, n.isOdd, n.isMultiple(of:) •

    ࠷ޙ୞༗ n.isMultiple(of:) ௨աɼ။Ճ౸ Swift 5 ཫɻ • ֩৺ᅶୂ᧷ಘ isEven Ṝछ؆ᄸతେՈࣗݾሜब޷ɻ ر๬ೳ೺ޠݴతද໘ੵେখ߇੍޷ɻ
  10. [SE-0226] Package Manager Target Based Dependency Resolution • Ұݸ Package

    ཫ໘ৗৗ༗኷ଟෆಉ target, 㑌ݸ target ౎༗֤ࣗత dependencyɻݱࡏ༻ྃҰݸ Package ब။೺ॴ༗త dependency ౎፛ਐိɼ೭ ޙ୞။፛༗༻౸త targetɻ