-
-
Save riteshhgupta/358db2ed3b6968ef18880cb28bdb6963 to your computer and use it in GitHub Desktop.
This file contains 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
+1 for above