Skip to content

Instantly share code, notes, and snippets.

View Meseery's full-sized avatar
🏠
Working from home

Mohamed EL Meseery Meseery

🏠
Working from home
  • Vodafone
  • Egypt
View GitHub Profile
@Meseery
Meseery / Awesome Swift Optional
Last active February 15, 2017 02:32
Two blocks for any optional :one if nil and another if not .. simple nil checking !
`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()
}
}
}`