Swift weekly 2018/09/04

3f7d9611fc919c98512b779cde637dfc?s=47 Johnlin
September 04, 2018

Swift weekly 2018/09/04

3f7d9611fc919c98512b779cde637dfc?s=128

Johnlin

September 04, 2018
Tweet

Transcript

  1. 3.

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

    • ໨ඪ: ABI stability (again) ɼแؚ generic, API resilience, memory ownership model • ။޲Լ૬༰ 4
  2. 4.

    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. 5.

    [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. 6.

    [SE-0220] count(where:) [1,2,3,4,5,6,7].reduce(0) { $0 + ($1 % 2 ==

    0 ? 1 : 0) } • Ṝᒬతሜ๏䋯తൺֱշɼୠੋ኷೉䔟㣛ੋࡏ၏ॄኄɻ
  5. 7.

    [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. 9.

    [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. 10.

    [SE-0224] Support 'less than' operator in compilation conditions #if swift(<5.0)

    print("this is not 5.0") #endif • ೭ޙՄҎ༻ < ိ൑Ꮧ Swift ൛ຊ
  8. 11.

    [SE-0225] isEven, isOdd, isMultiple • ᧷ಘ㑌࣍౎ཁሜ n % 2 ==

    0 ኷൥䆩ʁ • େՈ᧷ಘ -3 % 2 ੋଟগ䏆ʁ
  9. 12.

    [SE-0225] isEven, isOdd, isMultiple • ༗ਓఏҊཁՃ n.isEven, n.isOdd, n.isMultiple(of:) •

    ࠷ޙ୞༗ n.isMultiple(of:) ௨աɼ။Ճ౸ Swift 5 ཫɻ • ֩৺ᅶୂ᧷ಘ isEven Ṝछ؆ᄸతେՈࣗݾሜब޷ɻ ر๬ೳ೺ޠݴతද໘ੵେখ߇੍޷ɻ
  10. 13.

    [SE-0226] Package Manager Target Based Dependency Resolution • Ұݸ Package

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