A Swift introduction

A Swift introduction

Since its initial release in 2014 and subsequent open-sourcing in 2015 Swift has become one of the most popular programming languages in the world — used everywhere from mobile to Macs to microservices. We will examine the various similarities and differences between Swift and other languages, and take a peek at the unique community that has formed around it.

20cd0627a5c82f8b3e4f30a04745f0cf?s=128

Neil Kimmett

February 21, 2017
Tweet

Transcript

  1. a Swift introduction by @neilkimmett

  2. What is ?

  3. None
  4. func move(from start: Point, to end: Point) -> Distance

  5. func move(from start: Point, to end: Point) -> Distance player.move(from:

    here, to: there)
  6. let names: [String] = ["Jeff", "Samantha", "T-Pain"]

  7. let names: [String] = ["Jeff", "Samantha", "T-Pain"] names.map({ (string: String)

    in return string.appending(" is super cool!") })
  8. let names: [String] = ["Jeff", "Samantha", "T-Pain"] names.map({ (string: String)

    in return string.appending(" is super cool!") })
  9. let names = ["Jeff", "Samantha", "T-Pain"] names.map({ (string: String) in

    return string.appending(" is super cool!") })
  10. let names = ["Jeff", "Samantha", "T-Pain"] names.map({ (string: String) in

    return string.appending(" is super cool!") })
  11. let names = ["Jeff", "Samantha", "T-Pain"] names.map({ string in return

    string.appending(" is super cool!") })
  12. let names = ["Jeff", "Samantha", "T-Pain"] names.map { string in

    return string.appending(" is super cool!") }
  13. let names = ["Jeff", "Samantha", "T-Pain"] names.map { $0.appending(" is

    super cool!”) }
  14. class Person { }

  15. class Person { var name: String let dateOfBirth: Date }

  16. class Person { var name: String let dateOfBirth: Date init(dateOfBirth:

    Date, name: String) { self.dateOfBirth = dateOfBirth self.name = name } }
  17. class Person { var name: String let dateOfBirth: Date init(dateOfBirth:

    Date, name: String) { self.dateOfBirth = dateOfBirth self.name = name } func dayOfBirth() -> DayOfWeek { return … } }
  18. struct Date { … }

  19. struct DateFormatter { }

  20. struct DateFormatter { let format: String }

  21. struct DateFormatter { let format: String func date(from string: String)

    -> Date }
  22. func date(from string: String) -> Date { … return nil

    } ?
  23. let userInput = "1989-08-27"

  24. let userInput = "1989-08-27" let formatter = DateFormatter(format: "YYYY-MM-DD")

  25. let userInput = "1989-08-27" let formatter = DateFormatter(format: "YYYY-MM-DD") let

    maybeDate = formatter.date(from: userInput)
  26. let userInput = "1989-08-27" let formatter = DateFormatter(format: "YYYY-MM-DD") let

    maybeDate = formatter.date(from: userInput) if let date = maybeDate { … }
  27. enum DayOfWeek { }

  28. enum DayOfWeek { case Mon, Tue, Wed, Thu, Fri, Sat,

    Sun }
  29. enum DayOfWeek { case Mon, Tue, Wed, Thu, Fri, Sat,

    Sun func isWeekend() -> Bool { switch self { case .Mon, .Tue, .Wed, .Thu, .Fri return false case .Sat, .Sun return true } }
  30. let maybeDate = formatter.date(from: string) if let date = maybeDate

    { let person = Person(dateOfBirth: date, name: name) if person.dayOfBirth().isWeekend() { … } }
  31. swift.org github.com/apple/swift

  32. github.com/apple/swift-evolution/

  33. Kitura Vapor

  34. Thanks! from @neilkimmett HARRY’S.com