Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public protocol Occupiable {
var isEmpty: Bool { get }
var isNotEmpty: Bool { get }
}
public extension Occupiable {
public var isNotEmpty: Bool { return !isEmpty }
}
extension CollectionType where Self : Occupiable { }
extension String: Occupiable { }
public extension Optional where Wrapped : Occupiable {
var isNilOrEmpty: Bool {
return self?.isEmpty ?? false
}
var isNotNilOrEmpty: Bool {
return !isNilOrEmpty
}
}
let ar = [1, 2, 3, 4, 5]
ar.isNotEmpty
let optAr: [Int]? = [1, 2, 3, 4, 5]
optAr.isNilOrEmpty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.