Assume we have nullable val a: Boolean?
.
In code we want to assign value of a
to another non-nullable variable val b: Boolean
.
If a
is true
then we want b
also to be true
If a
is false
or null
the we want b
to be false
.
We can do this in 2 ways:
b = a ?: false
or
b = a == true
Which of the following approaches is better in terms of performance?