Swift编程语言提到使用isEmpty来检查空字符串.是否存在检查字符串与""不会产生与使用isEmpty相同的结果的情况?
换一种说法:
if str.isEmpty {
XCTAssert(str == "", "This should be true as well")
}
Run Code Online (Sandbox Code Playgroud)
从文档:
通过检查其布尔值isEmpty属性,确定String值是否为空:
if emptyString.isEmpty {
print("Nothing to see here")
}
Run Code Online (Sandbox Code Playgroud)