我想在 android 中检查我的 EditText 的值,所以我看到了我的 String 值的两个函数:
user.isNullOrBlank()
和
user.isNullOrEmpty()
它们之间有什么区别?
Com*_*are 57
isNullOrBlank()
考虑空格:
fun main() {
val thisIsBlank = " "
println(thisIsBlank.isNullOrEmpty())
println(thisIsBlank.isNullOrBlank())
}
Run Code Online (Sandbox Code Playgroud)
这打印:
false
true
Run Code Online (Sandbox Code Playgroud)
因为thisIsBlank
不是空的,而是空的。
For*_*est 15
isNullOrEmpty()
isNullOrBlank()
归档时间: |
|
查看次数: |
4781 次 |
最近记录: |