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

The Pledge, the Turn, the Prestige: Keeping in ...

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.
Avatar for Bas Broek Bas Broek
January 18, 2018

The Pledge, the Turn, the Prestige: Keeping in Touch With Swift

Presented on 18.01.2017

Avatar for Bas Broek

Bas Broek

January 18, 2018
Tweet

More Decks by Bas Broek

Other Decks in Programming

Transcript

  1. SWIFT 4 > Codable > String is a collection again

    > "Better" imterpretation of grapheme clusters > Multi-Line String Literals > Dictionary and Set enhancements > Access Control ( ) > Keypaths (some are already using it!) > Standard Library Improvements > ... and more to come 4 — Bas Broek, 18.01.2017
  2. Codable struct Person: Codable { public let name: String }

    let person = Person(name: "Bas") let payload = try JSONEncoder().encode(person) let string = String(data: payload, encoding: .utf8) // {"name":"Bas"} let decodedPerson = try JSONDecoder().decode(Person.self, from: payload) // Person(name: "Bas") 5 — Bas Broek, 18.01.2017
  3. String let world = "hello, world".count // 12 let family

    = " ! ".count // 1 let multiline = """ { "hello": "world", "multiple": [ "one": 1, "two": 2 ] } """ 6 — Bas Broek, 18.01.2017
  4. Dictionary & Set let source = "hello, world" var frequencies:

    [Character: Int] = [:] source.map { frequencies[$0, default: 0] += 1 } frequencies // ["w": 1, "r": 1, "e": 1, "o": 2, "l": 3, ",": 1, " ": 1, "h": 1, "d": 1] let x = frequencies["a", default: 0] // Does not store `0` at `a`; let y = frequencies["a"] ?? 0 // these lines are equivalent let numbers = ["one": 1, "two": 2, "three": 3, "four": 4] let strings = numbers.mapValues(String.init) // ["three": "3", "four": "4", "one": "1", "two": "2"] let evens = numbers.filter { $0.value % 2 == 0 } // ["four": 4, "two": 2] 7 — Bas Broek, 18.01.2017
  5. ACCESS CONTROL struct Song { let artist: String let name:

    String private var _description: String { return "\(artist) - \(name)" } } extension Song: CustomStringConvertible { var description: String { return _description } } Song(artist: "Rick Astley", name: "Never Gonna Give You Up") // OK! 8 — Bas Broek, 18.01.2017
  6. KEYPATHS See the code here. stateModel.observe(\.currentState, options: [.new]) { [weak

    self] _, change in if change.newValue == nil { return } self?.configureSectionIndexBarForCurrentState() } 9 — Bas Broek, 18.01.2017
  7. STAND LIBRARY IMPROVEMENTS var collection = ["a", "b"] collection.swapAt(0, 1)

    // ["b", "a"] protocol P {} struct S: P {} class C: P {} let u: AnyObject & P = C() // Compiles successfully 10 — Bas Broek, 18.01.2017
  8. SWIFT 5 > ABI Stability (Application Binary Interface) > (Start

    on) Memory Ownership Model > (Stricter) Source Stability > String Ergonomics > Improvements to the Standard Library > Foundation Improvements > Syntactic additions > Laying the groundwork for a new Concurrency Model > Proposals need a working implementation > ... and more? 13 — Bas Broek, 18.01.2017
  9. SWIFT WEEKLY BRIEF > What is it? > I will

    be curating it starting 25.01.2018 (please do *not* communicate until then) > I would ❤ your input, but don't feel any obligations! > Proofreading, providing interesting links or (help) writing an issue > It is Open Source on GitHub 15 — Bas Broek, 18.01.2017
  10. The newsletter is definitely a valuable resource for the community,

    and if you want to help it live on, it will have a huge impact. There are thousands of followers and subscribers. — Jesse Squires 16 — Bas Broek, 18.01.2017
  11. REFERENCES SWIFT 4 > SE-0166: Swift Archival & Serialization >

    SE-0163: String Revision > SE-0165: Dictionary & Set Enhancements > SE-0169: Improve Interaction Between private Declarations and Extensions > SE-0161: Smart KeyPaths: Better Key-Value Coding for Swift > SE-0168: Multi-Line String Literals > SE-0173: Add MutableCollection.swapAt(_:_:) > SE-0156: Class and Subtype Existentials > SE-0185: Synthesizing Equatable and Hashable conformance > What's New in Swift 4? 18 — Bas Broek, 18.01.2017
  12. REFERENCES SWIFT 5 > What's up With Swift 5? >

    Primary Focus: ABI Stability 19 — Bas Broek, 18.01.2017