Slide 1

Slide 1 text

a Swift introduction by @neilkimmett

Slide 2

Slide 2 text

What is ?

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

let names: [String] = ["Jeff", "Samantha", "T-Pain"]

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

class Person { }

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

class Person { var name: String let dateOfBirth: Date init(dateOfBirth: Date, name: String) { self.dateOfBirth = dateOfBirth self.name = name } func dayOfBirth() -> DayOfWeek { return … } }

Slide 18

Slide 18 text

struct Date { … }

Slide 19

Slide 19 text

struct DateFormatter { }

Slide 20

Slide 20 text

struct DateFormatter { let format: String }

Slide 21

Slide 21 text

struct DateFormatter { let format: String func date(from string: String) -> Date }

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

let userInput = "1989-08-27"

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

enum DayOfWeek { }

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

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 } }

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

swift.org github.com/apple/swift

Slide 32

Slide 32 text

github.com/apple/swift-evolution/

Slide 33

Slide 33 text

Kitura Vapor

Slide 34

Slide 34 text

Thanks! from @neilkimmett HARRY’S.com