This is not a duplicate of any of the dozens questions with that title, which I have studied.
- Sorry if I am dense but bear with me, as i haven’t been able to understand clearly the difference between ? and !, after reading about everything:
For instance, a common exclamation is:
?: I dont know whether it is null or not.
!: Be careful! This might be null.
!!: Be careful, and yes I know it. This is always not null.
But then, wouldn’t this mean that ? and ! mean actually the same logical thing, that the variable can be null or not.
- So I got a function in java that returns this:
— kotlin.Array<(out) java.security.cert.X509Certificate!>?
because each certificate in the array may or may not be null
Then why would I not be able to just assign into a variable as so:
— kotlin.Array<(out) java.security.cert.X509Certificate?>?
Which would tell kotlin that, drum roll, each certificate may or may not be null.
So here is the question, I got:
val c1 = javafunction()
Where c1 is of the type kotlin.Array<(out) java.security.cert.X509Certificate!>?
How can I assign c1 into c2:
val c2 : kotlin.Array<(out) java.security.cert.X509Certificate?>? = XXXX