Short question which came up at work: Is there a s...
# android
d
Short question which came up at work: Is there a save way to access the ::class.java from a nullable type?
Copy code
val activityNonNull: Activity = Activity()

        Log.d("Test", "${activityNonNull::class.java}")

        val activityNullable: Activity? = Activity()

        Log.d("Test", "${activityNullable::class.java}")
In the last line the compiler rightfully forbids the
activityNullable::class.java
since
activityNullable
can be null. Might there be a syntax like the save call operator for this case? To prevent wrapping everything in an
if
.