I have two nullable ancapsulated objects like:
class NullableObject(
val a : AnotherNullable? = null
val b : String = "b"
}
class AnotherNullable(val id: String) {
val hash: Integer? = someHashFunction(id)
val hashInvalidHash: Boolean = (hash == null)
}
where I use the not()
operator like:
val hasAnotherNullableHash = nullableObject?.anotherNullableObject?.hasInvalidHash.not() ?: false
I read the hasInvalidHash
property or set a default false
if either nullableObject
or anotherNullableObject
were null ..
Question:
How to I transform this .not()
operator to the unary !
?
val hasAnotherNullableHash = !nullableObject?.anotherNullableObject?.hasInvalidHash!!
I have to !!
and the default value false
is also not possible..