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 { | |
// `ifNotNil` function executes the closure if there is some value | |
func ifNotNil(_ handler: (Wrapped) -> Void, ifNil failure: () -> Void) { | |
switch self { | |
case .some(let wrapped): return handler(wrapped) | |
case .none:return failure() | |
} | |
} | |
}` |