extension String{
/// check string cellection is whiteSpace
var isBlank : Bool{
return allSatisfy({$0.isWhitespace})
}
}
extension Optional where Wrapped == String{
var isBlank : Bool{
return self?.isBlank ?? true
}
}
var title: String? = nil
title.isBlank // true
title = ""
title.isBlank // true
title = " \t "
title.isBlank // true
title = "Hello"
title.isBlank // false
网友评论