Forked from riteshhgupta/swift-snippet-9.swift
Last active
February 25, 2017 12:33
-
-
Save maciejpiotrowski89/db1932cb8a71ef4b970bb43cb09f3d68 to your computer and use it in GitHub Desktop.
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
| extension Optional { | |
| // `then` function executes the closure if there is some value | |
| func then(_ handler: (Wrapped) -> Void) { | |
| switch self { | |
| case .some(let wrapped): return handler(wrapped) | |
| case .none: break | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment