Sign in to FlowVella

Forgot password?
Sign in with Facebook

New? Create your account

Sign up for FlowVella

Sign up with Facebook

Already have an account? Sign in now


By registering you are agreeing to our
Terms of Service

Share This Flow

Loading Flow

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Manning, Jon, Paris Buttfield-Addison, and Tim Nugent. Swift Development with Cocoa. O'Reilly Media, 2014

Functions can be nested.

Functions are a

first-class type

Functions can optionally have external parameter names

Functions:

Value Capture

func createIncrementor(incrementAmount: Int) -> () -> Int {

    var amount = 0

    func incrementor() -> Int {

        amount += incrementAmount

        return amount

    }

    return incrementor

}


var incrementByTen = createIncrementor(10)

incrementByTen() //10

incrementByTen() //20


var incrementByFifteen = createIncrementor(15)

incrementByFifteen() //15

incrementByFifteen() //30


Due to time constraints, we decided to remove a discussion of value capture from our presentation.

But it's still interesting, so read and enjoy!

Downloading Image /

loading...

Downloading Image /

loading...
  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10

  • 11

  • 12

  • 13

  • 14

  • 15

  • 16

  • 17

  • 18

  • 19

  • 20

  • 21

  • 22

  • 23

  • 24

  • 25

  • 26

  • 27

  • 28

  • 29

  • 30

Introduction to the Swift Language - Chicago Swift Developer Meetup

By Matt Houser

v 2015-04-13a