07-20-2023, 02:26 PM
Is there a clean way in Kotlin to assign a value to a variable only if the value is not null?
My example is:
if(x != null)
y = x
I found a solution like
y = x? : return
but I don't understand if this does what I want and how this operator works.
My example is:
if(x != null)
y = x
I found a solution like
y = x? : return
but I don't understand if this does what I want and how this operator works.