Created
May 12, 2020 23:33
-
-
Save jimmyhoran/d56c9e577b7d8e1d8c4359d10f03ce98 to your computer and use it in GitHub Desktop.
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 where Wrapped: Collection { | |
var isNilOrEmpty: Bool { | |
return self?.isEmpty ?? true | |
} | |
} | |
// MARK: - Tests | |
func testNilOrEmpty() { | |
let nilString: String? = nil | |
XCTAssertTrue(nilString.isNilOrEmpty) | |
let emptyString: String? = "" | |
XCTAssertTrue(emptyString.isNilOrEmpty) | |
let someText: String? = "lorem" | |
XCTAssertFalse(someText.isNilOrEmpty) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment