在 Kotlin 中进行空检查的最佳方法? [英] Best way to null check in Kotlin?
本文介绍了在 Kotlin 中进行空检查的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我应该使用双重 =
还是三重 =
?
Should I use double =
, or triple =
?
if(a === null) {
//do something
}
或
if(a == null) {
//do something
}
类似于不等于":
if(a !== null) {
//do something
}
或
if(a != null) {
//do something
}
推荐答案
两种方法生成相同的字节码,因此您可以选择任何您喜欢的方式.
Both approaches generate the same bytecode so you can choose whatever you prefer.
这篇关于在 Kotlin 中进行空检查的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文