Skip to content

Instantly share code, notes, and snippets.

@AppleCEO
Created June 13, 2019 12:19
Show Gist options
  • Select an option

  • Save AppleCEO/523bad86d44175bab9bd8d913883284f to your computer and use it in GitHub Desktop.

Select an option

Save AppleCEO/523bad86d44175bab9bd8d913883284f to your computer and use it in GitHub Desktop.
Optional is monad
let optional:Optional = 1
let optionalReturned = optional.map({ (number: Int) -> Int in
let result = 2 * number
return result
}).map({ (number: Int) -> Int in
let result = number / 2
return result
})
optional == optionalReturned
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment