Skip to content

Instantly share code, notes, and snippets.

@dimohamdy
Created March 29, 2020 22:18
Show Gist options
  • Save dimohamdy/a9cb9daf859c6475711669c5049172df to your computer and use it in GitHub Desktop.
Save dimohamdy/a9cb9daf859c6475711669c5049172df to your computer and use it in GitHub Desktop.
import Foundation
extension Optional where Wrapped: Collection {
public var isNilOrEmpty: Bool {
switch self {
case .none:
return true
case .some(let collection):
return collection.isEmpty
}
}
}
@dimohamdy
Copy link
Author

dimohamdy commented Mar 29, 2020

import Foundation

extension Optional where Wrapped: Collection {
    public var isNilOrEmpty: Bool {
        return self?.isEmpty ?? true
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment