Created
June 13, 2019 12:19
-
-
Save AppleCEO/523bad86d44175bab9bd8d913883284f to your computer and use it in GitHub Desktop.
Optional is monad
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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