Hi. I'd like to check whether `null` property is e...
# getting-started
s
Hi. I'd like to check whether
null
property is exists in data class. Should I check for each property like as below? Or there is other good way?
Copy code
data class Book(val name: String?, val author: String?, val price: Int?)

fun isExistNull(): Boolean {
    if (name == null || author == null || price == null) {
        return true
    }
    return false
}
j
return (name == null || author == null || price == null)
is sufficient. But other than that, yes, it’s the straightforward way to do it.
👍 1
n
name ?: author ?: price ?: true == true
should also work
👍 1