Add more Optional extensions:
// check if optional is nil or empty collection
public extension Optional where Wrapped: Collection {
public var isNilOrEmpty: Bool { ... }
}
Here are some unit tests to include to check if you've done this correctly:
func testIsNilOrEmpty() {
let nilArray: [String]? = nil
XCTAssertTrue(nilArray.isNilOrEmpty)
let emptyArray: [String] = []
XCTAssertTrue(emptyArray.isNilOrEmpty)
let intArray: [Int] = [1]
XCTAssertFalse(intArray.isNilOrEmpty)
let optionalArray: [Int]? = [1]
XCTAssertFalse(optionalArray.isNilOrEmpty)
}
String is a collection :trollface:
Didn't know Github has a :trollface: emoji 馃槀
Most helpful comment
String is a collection :trollface: