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

A Swift introduction

Avatar for Neil Kimmett Neil Kimmett
February 21, 2017

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.

Avatar for Neil Kimmett

Neil Kimmett

February 21, 2017
Tweet

More Decks by Neil Kimmett

Other Decks in Technology

Transcript

  1. let names = ["Jeff", "Samantha", "T-Pain"] names.map { string in

    return string.appending(" is super cool!") }
  2. class Person { var name: String let dateOfBirth: Date init(dateOfBirth:

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

    Date, name: String) { self.dateOfBirth = dateOfBirth self.name = name } func dayOfBirth() -> DayOfWeek { return … } }
  4. let userInput = "1989-08-27" let formatter = DateFormatter(format: "YYYY-MM-DD") let

    maybeDate = formatter.date(from: userInput) if let date = maybeDate { … }
  5. 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 } }
  6. let maybeDate = formatter.date(from: string) if let date = maybeDate

    { let person = Person(dateOfBirth: date, name: name) if person.dayOfBirth().isWeekend() { … } }