在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屋!
查看全文